home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / util / shell / zshellsrc.lha / ZShell.S < prev   
Text File  |  1995-09-13  |  257KB  |  12,792 lines

  1.     
  2. ****************************************************
  3. *********  ZSHELL (C) 1990,91 Paul Hayter  *********
  4. ********  updated to V2.8 by Martin Gierich ********
  5. ********    First major change: 08.06.93    ********
  6. *********    Last change: 10.09.95       *********
  7. ****************************************************
  8.  
  9. **ZShell V2.8.6, Changes since V2.7:
  10. *FNC allows wildcards
  11. *CONFIG LOGFILE [filename]
  12. *No space before | needed
  13. *Better handling of \ and rediretors
  14. *CTRL-F behaves similar to FNC
  15. *Fixed 2 Enforcerhits
  16. *Command line parser
  17. *MEMCLK checks font
  18. *FNC: Backtick cycles back
  19. *Parser: Shows missing spaces
  20. *Checking for too many arguments
  21. *COPY: Dotchar as dest. is last dir
  22. *\ escapes aliases
  23. *FNC checks windowsize
  24. *Multiple lines editing
  25. *Function keys support macros, ALIAS F or ALIAS SF (shifted)
  26. *ALIAS uses memory pools
  27. *Scripts: \ escapes LF
  28. *(KILL command uses pr_ExitCode)
  29. *(COMPARE source dest [offset1 offset2])
  30.  
  31. ;DEBUG    = 1
  32. ;KILL    = 1
  33.  
  34. ***        TABSIZE = 8 Chars         ***
  35. ***     Local Labels named .A to .Z         ***
  36.  
  37. ;ZSH V2.2 needs:
  38. ;sizeofblk=3944
  39. ;VCheck-start=222
  40. ;JumpIn-start=244
  41.  
  42. ;Sizes in bytes:
  43. ;Cmdline editor: 3300 (including FNC: 900)
  44. ;Cmdline parser: 2100
  45. ;External cmd starter: 1000
  46. ;Dir lister: 2600
  47. ;COPY: Dir lister + 900
  48. ;ASSIGN: 1200
  49. ;MORE: 1100
  50. ;REVIEW + Handler: 800
  51. ;MEMCLK: 650
  52. ;INFO: 450
  53. ;RENAME: 26
  54. ;CLS: 12
  55.  
  56. VERSION        = $1234
  57. POOLSIZE    = 2000
  58.  
  59. FLcheck        = 0    byte 3
  60. FLmatch        = 1
  61. FLappicon    = 2
  62. FLwild        = 3
  63. FLerrors    = 4
  64. FLdebug        = 5
  65. FLcutline    = 6
  66. FLall        = 7
  67. FLhide        = 0    byte 2
  68. FLpipe        = 1
  69. MaxFlags     = 10
  70.  
  71. FLraw        = 2
  72.  
  73. FIB            equ    260        ;FileInfoBlock
  74. ACCESS_READ        equ    -2
  75. ACCESS_WRITE        equ    -1
  76. MODE_READWRITE        equ    1004
  77. MODE_OLDFILE        equ    1005
  78. MODE_NEWFILE        equ    1006
  79.  
  80. SIGBREAKB_CTRL_C    equ    $C
  81. SIGBREAKB_CTRL_D    equ    $D
  82. SIGBREAKB_CTRL_E    equ    $E
  83. SIGBREAKB_CTRL_F    equ    $F
  84.  
  85. eb_CoolCapture    equ    46
  86. eb_ColdCapture    equ    42
  87. eb_WarmCapture    equ    50
  88. eb_KickMemPtr    equ    546
  89. eb_KickTagPtr    equ    550
  90. eb_KickCheckSum    equ    554
  91.     
  92. * FILE INFO BLOCK
  93. fib_DiskKey        equ  $0000
  94. fib_DirEntryType    equ  $0004
  95. fib_FileName        equ  $0008
  96. fib_Protection        equ  $0074
  97. fib_EntryType        equ  $0078
  98. fib_Size        equ  $007c
  99. fib_NumBlocks        equ  $0080
  100. fib_Date        equ  $0084
  101. fib_Comment        equ  $0090
  102. fib_Reserved        equ  $00e0
  103.  
  104. * INFO DATA STRUCTURE
  105. id_NumSoftErrors    equ    0
  106. id_UnitNumber        equ    4
  107. id_DiskState        equ    8
  108. id_NumBlocks        equ    12
  109. id_NumBlocksUsed    equ    16
  110. id_BytesPerBlock    equ    20
  111. id_DiskType        equ    24
  112. id_VolumeNode        equ    28
  113. id_InUse        equ    32
  114.  
  115. * TASK
  116. tc_State        equ    15
  117. tc_SigWait        equ    22
  118.  
  119. * PROCESS
  120.  
  121. pr_MsgPort        equ    92
  122. pr_SegList        equ    128
  123. pr_StackSize        equ    132
  124. pr_GlobVec        equ    136
  125. pr_TaskNum        equ    140
  126. pr_StackBase        equ    144
  127. pr_Result2        equ    148
  128. pr_CurrentDir        equ    152
  129. pr_CIS            equ    156
  130. pr_COS            equ    160
  131. pr_ConsoleTask        equ    164
  132. pr_FileSystemTask    equ    168
  133. pr_CLI            equ    172
  134. pr_ReturnAddr        equ    176
  135. pr_PktWait        equ    180
  136. pr_WindowPtr        equ    184
  137. pr_HomeDir        equ    188    KS2
  138. pr_Flags        equ    192
  139. pr_ExitCode        equ    196
  140. pr_ExitData        equ    200
  141. pr_CES            equ    224
  142.  
  143. * COMMAND LINE INTERFACE
  144. cli_Result        equ    0
  145. cli_SetName        equ    4
  146. cli_CommandDir        equ    8
  147. cli_ReturnCode        equ    12
  148. cli_CommandName        equ    16
  149. cli_FailLevel        equ    20
  150. cli_Prompt        equ    24
  151. cli_StandardInput    equ    28
  152. cli_CurrentInput    equ    32
  153. cli_CommandFile        equ    36
  154. cli_Interactive        equ    40
  155. cli_Background        equ    44
  156. cli_CurrentOutput    equ    48
  157. cli_DefaultStack    equ    52
  158. cli_StandardOutput    equ    56
  159. cli_Module        equ    60
  160.  
  161. * FILE HANDLE
  162. fh_Link            equ    0
  163. fh_Port            equ    4
  164. fh_Type            equ    8
  165. fh_Buf            equ    12
  166. fh_Pos            equ    16
  167. fh_End            equ    20
  168.  
  169. * FILE LOCK
  170. fl_Link            equ    0
  171. fl_Key            equ    4
  172. fl_Access        equ    8
  173. fl_Task            equ    12
  174. fl_Volume        equ    16
  175.  
  176. * DATESTAMP
  177. ds_Days            equ    0
  178. ds_Minute        equ    4
  179. ds_Tick            equ    8
  180.  
  181. RETURN_OK        EQU  0
  182. RETURN_WARN        EQU  5
  183. RETURN_ERROR        EQU  10
  184. RETURN_BAD        EQU  15
  185. RETURN_FAIL        EQU  20
  186.  
  187. *Assign Stuff
  188. dl_Root        equ    34    APTR
  189. rn_Info        equ    24    BPTR
  190. rn_Flags    equ    52    LONG
  191. di_DevInfo    equ    4    BPTR
  192. di_NetHand    equ    16    BPTR
  193. dvi_Next    equ    0    BPTR
  194. dvi_Type    equ    4    LONG
  195. dvi_Task    equ    8    APTR
  196. dvi_Lock    equ    12    BPTR
  197. dvi_Handler    equ    16    (PathPtr)
  198. dvi_StackSize    equ    20
  199. dvi_LockList    equ    20
  200. dvi_Priority    equ    24
  201. dvi_Startup    equ    28
  202. dvi_SegList    equ    32
  203. dvi_GlobVec    equ    36
  204. dvi_Name    equ    40    BSTR
  205. dlt_device    equ    0    <-- contents of dvi_Type
  206. dlt_directory    equ    1
  207. dlt_volume    equ    2
  208. dlt_late    equ    3
  209. dlt_nonbind    equ    4
  210.  
  211. *Resident Stuff
  212. resi_link    equ    0    ;BPTR
  213. resi_usecount    equ    4    ;LONG
  214. resi_seglist    equ    8    ;BPTR
  215. resi_name    equ    12    ;BSTR
  216. resi_length    equ    4+4+4
  217.  
  218. *Icon Lib Stuff
  219. sm_Process    equ    $14
  220. sm_Segment    equ    $18
  221. sm_NumArgs    equ    $1c
  222. sm_ToolWindow    equ    $20
  223. sm_ArgList    equ    $24
  224. wa_Lock        equ    0
  225. wa_Name        equ    4
  226. do_Magic    equ    0    ;must be $e310
  227. do_Type        equ    $30
  228. do_ToolTypes    equ    $36
  229. do_ToolWindow    equ    $46
  230. do_StackSize    equ    $4a
  231.  
  232. *WAppMessage
  233. am_Type        equ    20
  234. am_NumArgs    equ    30
  235. am_ArgList    equ    34
  236.  
  237. * AVAIL STUFF
  238. MEMF_PUBLIC        equ 1
  239. MEMF_CHIP        equ 2
  240. MEMF_FAST        equ 4
  241. MEMF_CLEAR        equ $10000
  242. MEMF_LARGEST        equ $20000
  243.  
  244. * ACTIONS
  245. ACTION_SCREEN_MODE    EQU    994
  246. ACTION_INHIBIT        EQU    31
  247. ACTION_MORE_CACHE    EQU    18
  248. ACTION_RENAME_DISK    EQU    9
  249. ACTION_DIE        EQU    5
  250. ACTION_DISK_CHANGE    EQU    33
  251. ACTION_SET_DATE        EQU    34
  252. ACTION_DISK_INFO    EQU    25
  253. ACTION_WRITE_PROTECT    EQU    1023
  254. ACTION_FLUSH        EQU    27
  255. ACTION_READ        EQU    "R"
  256. ACTION_WRITE        EQU    "W"
  257.  
  258. dp_Link        EQU  $00   ;DosPacket Structure
  259. dp_Port        EQU  $04
  260. dp_Type        EQU  $08
  261. dp_Arg1        EQU  $14
  262. dp_SIZEOF    EQU  $30
  263.  
  264. sp_Msg        EQU  $00   ;StandardPacket Structure
  265. sp_Pkt        EQU  $14
  266. sp_SIZEOF    EQU  $44
  267.  
  268. LH_HEAD        equ    0
  269. LH_TAIL        equ    4
  270. LH_TAILPRED    equ    8
  271. LH_TYPE        equ    12
  272. LH_PAD        equ    13
  273. LH_SIZE        equ    14
  274.  
  275. LN_SUCC        equ    0
  276. LN_PRED        equ    4
  277. LN_TYPE        equ    8
  278. LN_PRI        equ    9
  279. LN_NAME        equ    10
  280. LN_SIZE        equ    14
  281.  
  282. NT_MSGPORT    EQU  4
  283.  
  284. MP_FLAGS    EQU  $0E   ;Message Port Structure
  285. MP_SIGBIT    EQU  $0F   ;Signal bit number
  286. MP_SIGTASK    EQU  $10   ;Task to be signalled
  287. MP_MSGLIST    EQU  $14   ;Message linked list
  288. MP_SIZE        EQU  $22
  289.  
  290. mn_ReplyPort    equ    14
  291. mn_Length    equ    18
  292. mn_Size        equ    20
  293.  
  294. PA_SIGNAL    EQU  0       ;PutAction messages
  295.  
  296.  
  297. TAG_USER    equ    $80000000
  298. ASL_TB        equ    TAG_USER!$80000
  299.  
  300. * LIBRARY CALLS
  301. * EXEC
  302. _LVOOpenLibrary        equ    -552
  303. _LVOOldOpenLibrary    equ    -408
  304. _LVOCloseLibrary    equ    -414
  305. _LVOSetFunction        equ    -420
  306. _LVOAllocMem        equ    -198
  307. _LVOFreeMem        equ    -210
  308. _LVORawDoFmt        equ    -522
  309. _LVORawMayGetChar    equ    -510
  310. _LVOFindTask        equ    -294
  311. _LVOSetTaskPri        equ    -300
  312. _LVOAddTask        equ    -282
  313. _LVORemTask        equ    -288
  314. _LVOForbid        equ    -132
  315. _LVOPermit        equ    -138
  316. _LVOAvailMem        equ    -216
  317. _LVOAddPort        equ    -354
  318. _LVORemPort        equ    -360
  319. _LVOFindPort        equ    -390
  320. _LVOPutMsg        equ    -366
  321. _LVOGetMsg        equ    -372
  322. _LVOReplyMsg        equ    -378
  323. _LVOWaitPort        equ    -384
  324. _LVOWait        equ    -318
  325. _LVOSignal        equ    -324
  326. _LVOSetSignal        equ    -306
  327. _LVOAllocSignal        equ    -330
  328. _LVOFreeSignal        equ    -336
  329. _LVOOpenDev        equ    -444
  330. _LVOCloseDev        equ    -450
  331. _LVODoIO        equ    -456
  332. _LVOCreateMsgPort    equ    -666    KS 2.0+
  333. _LVODeleteMsgPort    equ    -672
  334.  
  335. * DOS
  336. _LVOSetProtection    equ    -186
  337. _LVOExecute        equ    -222
  338. _LVOOutput        equ    -60
  339. _LVOWrite        equ    -48
  340. _LVOLock        equ    -84
  341. _LVOUnLock        equ    -90
  342. _LVODupLock        equ    -96
  343. _LVOExamine        equ    -102
  344. _LVOExNext        equ    -108
  345. _LVOOpen        equ    -30
  346. _LVOClose        equ    -36
  347. _LVORead        equ    -42
  348. _LVOInput        equ    -54
  349. _LVODeleteFile        equ    -72
  350. _LVORename        equ    -78
  351. _LVOCreateDir        equ    -120
  352. _LVOCurrentDir        equ    -126
  353. _LVOIoErr        equ    -132
  354. _LVOParentDir        equ    -210
  355. _LVOLoadSeg        equ    -150
  356. _LVOUnLoadSeg        equ    -156
  357. _LVOCreateProc        equ    -138
  358. _LVOInfo        equ    -114
  359. _LVODateStamp        equ    -192
  360. _LVOSeek        equ    -66
  361. _LVODeviceProc        equ    -174
  362. _LVODelay        equ    -198
  363. _LVOSetComment        equ    -180
  364. _LVOIsInteractive    equ    -216
  365. _LVOReadLink        equ    -438    KS 2.0+
  366. _LVOMakeLink        equ    -444
  367. _LVOFault        equ    -468
  368. _LVOPrintFault        equ    -474
  369. _LVOAssignLock        equ    -612
  370. _LVOAssignLate        equ    -618
  371. _LVOAssignPath        equ    -624
  372. _LVOAssignAdd        equ    -630
  373. _LVORemAssignList    equ    -636
  374. _LVOFormat        equ    -714
  375. _LVOAddBuffers        equ    -732
  376. _LVOFilePart        equ    -870
  377. _LVOPathPart        equ    -876
  378. _LVOInhibit        equ    -726
  379. _LVOParsePatternNC    equ    -966
  380. _LVOMatchPatternNC    equ    -972
  381. _LVONameFromLock    equ    -402
  382.  
  383. *Intuition
  384. _LVOPrintIText        equ    -216
  385. _LVODisplayAlert    equ    -90
  386. _LVODisplayBeep        equ    -96
  387. _LVOLockIBase        equ    -414
  388. _LVOUnlockIBase        equ    -420
  389. _LVORefreshWindowFrame    equ    -456
  390. _LVOSizeWindow        equ    -288
  391. _LVOMoveWindow        equ    -168
  392. _LVOActivateWindow    equ    -450
  393. _LVORemakeDisplay    equ    -384
  394. _LVOMakeScreen        equ    -378
  395. _LVORethinkDisplay    equ    -390
  396. _LVOCloseScreen        equ    -66
  397. _LVOItemAddress        equ    -144
  398. _LVOSetMenuStrip    equ    -264
  399. _LVOClearMenuStrip    equ    -54
  400. _LVOOpenScreenTagList    equ    -612    KS2.0+
  401. _LVOPubScreenStatus    equ    -552
  402. _LVOLockPubScreen    equ    -510
  403. _LVOUnlockPubScreen    equ    -516
  404.  
  405. *Icon
  406. _LVOGetDiskObject    equ    -78
  407. _LVOGetDefDiskObject    equ    -120
  408. _LVOPutDiskObject    equ    -84
  409. _LVOFreeDiskObject    equ    -90
  410. _LVOFindToolType    equ    -96
  411. _LVOMatchToolValue    equ    -102
  412.  
  413. *Workbench
  414. _LVOAddAppIconA        equ    -60    KS2.0+
  415. _LVOAddAppWindowA    equ    -48
  416. _LVORemoveAppIcon    equ    -66
  417. _LVORemoveAppWindow    equ    -54
  418. _LVOWBInfo        equ    -90
  419.  
  420. *Utility
  421. _LVOToUpper        equ    -174    KS2.0+
  422. _LVOStricmp        equ    -162
  423. _LVOStrnicmp        equ    -168
  424.  
  425. *Asl
  426. _LVOAllocAslRequest    equ    -48    KS2.0+
  427. _LVOFreeAslRequest    equ    -54
  428. _LVOAslRequest        equ    -60
  429.  
  430. *XPKMaster
  431. _LVOXpkExamine        equ    -36
  432. _LVOXpkUnpack        equ    -48
  433.  
  434. *AmigaGuide
  435. _LVOOpenAmigaGuideA    equ    -54
  436. _LVOCloseAmigaGuide    equ    -66
  437.  
  438. *GadTools
  439. _LVOCreateMenusA    equ    -48
  440. _LVOFreeMenus        equ    -54
  441. _LVOLayoutMenuItemsA    equ    -60
  442. _LVOLayoutMenusA    equ    -66
  443. _LVOGetVisualInfoA    equ    -126
  444. _LVOFreeVisualInfo    equ    -132
  445.  
  446.  
  447. wd_WScreen    = 46
  448. wd_Flags    = 24
  449. wd_BorderLeft    equ    54
  450. mi_SIZEOF    = 34
  451. WFLG_NEWLOOKMENUS = $00200000
  452.  
  453. rf_File        = 4
  454. rf_Dir        = 8
  455.  
  456. XPK_InName    = $80005851    filename
  457. XPK_OutName    = $80005860    filename
  458. XPK_GetError    = $80005875    buffer
  459. XPK_TaskPri    = $8000587f    ubyte
  460.  
  461. *GadTools NewMenu structure
  462.         RSRESET
  463. gnm_Type    RS.B    1
  464. gnm_Pad        RS.B    1
  465. gnm_Label    RS.L    1
  466. gnm_CommKey    RS.L    1
  467. gnm_Flags    RS.W    1
  468. gnm_MutualExcl    RS.L    1
  469. gnm_UserData    RS.L    1
  470. gnm_SIZEOF    RS.W    0
  471.  
  472. NM_END        = 0
  473. NM_TITLE    = 1
  474. NM_ITEM        = 2
  475. NM_SUB        = 3
  476. NM_IGNORE    = 64
  477. NM_BARLABEL    = -1
  478. COMMSEQ        = 4
  479.  
  480. GT_TagBase        = TAG_USER+$80000
  481. GTMN_FullMenu        = 62+GT_TagBase
  482. GTMN_NewLookMenus    = 67+GT_TagBase
  483.  
  484.         RSRESET
  485. ;NewAmigaGuide-structure
  486. nag_Lock    RS.L    1
  487. nag_Name    RS.L    1
  488. nag_Screen    RS.L    1
  489. nag_PubScreen    RS.L    1
  490. nag_HostPort    RS.L    1
  491. nag_ClientPort    RS.L    1
  492. nag_BaseName    RS.L    1
  493. nag_Flags    RS.L    1
  494. nag_Context    RS.L    1
  495. nag_Node    RS.L    1
  496. nag_Line    RS.L    1
  497. nag_Extens    RS.L    1
  498. nag_Client    RS.L    1
  499. NewAmigaGuide_SIZEOF    RS.W    0
  500.  
  501. * DOS LIBRARY
  502. dl_A2            equ    42
  503.  
  504. *SYSTEM0 stuff!!!!!!!!!!
  505. REG_SysBase    equr a6
  506.  
  507. callsys    macro
  508.     jsr _LVO\1(REG_SysBase)
  509.     endm
  510.  
  511. * parameter offsets & stack
  512. ;SAVED_REGS    reg    a2-a6/d2-d3
  513. DELTA        equ    7*4
  514. ARG_NAME    equ    4+DELTA
  515. ARG_SEGLIST    equ    8+DELTA
  516. ARG_ARGS    equ    12+DELTA
  517.  
  518. * additional return codes
  519. NO_CLI        equ    -1
  520. NO_MEM        equ    -2
  521.  
  522. * local constants
  523. MAXBSTR        equ    255
  524. LF        equ    10
  525.  
  526. * register usage
  527. REG_Result    equr    d3
  528. REG_Process    equr    a2      ;may not be A4, see below!
  529. REG_CLI        equr    a3
  530. REG_CIS        equr    a4      ;may not be A3, see below!
  531. REG_PrevStack    equr    a1    ;V2.0 changed from a5 to a1
  532.  
  533. * local stack frame
  534. * STRUCTURE      StackFrame,0
  535.         RSRESET
  536. sf_CommandName    RS.B    MAXBSTR+1        ;BSTR, length byte!
  537. sf_CommandArgs    RS.B    MAXBSTR+1        ;not a BSTR, LF-terminated!
  538. sf_PrevStack        RS.L    1
  539. sf_SaveReturnAddr    RS.L    1
  540. sf_SaveModule        RS.L    1
  541. sf_SaveCommandName    RS.L    1
  542. sf_StackBase    RS.L    1
  543. sf_StackSize    RS.L    1
  544. sf_PushSize    RS.L    1
  545. sf_Process    RS.L    1
  546. sf_CLI        RS.L    1
  547. sf_CIS        RS.L    1
  548. sf_SCB_Buf    RS.L    1
  549. sf_SCB_Pos    RS.L    1
  550. sf_SCB_End    RS.L    1
  551. sf_Membase    RS.L    1
  552. sf_SIZEOF    RS.W    0
  553.  
  554. *Constants (only LONGS!)
  555. SHELLINE_SIZE    equ    256    V1.30
  556. CLIBUF_SIZE    equ    256
  557. NEWPRINTSIZE    equ    200
  558. HISTORY_SIZE    equ    1024    MUST BE POWER OF 2
  559.  
  560. * THE GENERAL MEMORY BLOCK (LONGS!)
  561.         RSRESET
  562. blockbase    RS.B    260    the fib or info goes here
  563. sp_node        RS.B    14    DOSpacket
  564. sp_reply    RS.L    1
  565. sp_length    RS.W    1
  566. sp_link        RS.L    1
  567. sp_port        RS.L    1
  568. packettype    RS.L    1
  569. sp_res1        RS.L    1
  570. sp_res2        RS.L    1
  571. myArg1        RS.L    1
  572. myArg2        RS.L    1
  573. myArg3        RS.L    1
  574. myArg4        RS.L    1
  575. myArg5        RS.L    1
  576. myArg6        RS.L    1
  577. myArg7        RS.L    1
  578. packettask    RS.L    1
  579. devproc        RS.L    1    endofpacket
  580. x1        RS.L    1
  581. last_failcode    RS.L    1
  582. outhandle    RS.L    1
  583. inhandle    RS.L    1
  584. x2        RS.B    40
  585. x3        RS.B    40
  586. stdout        RS.L    1
  587. stdin        RS.L    1
  588. EntryA0        RS.L    1
  589. better_Seglist    RS.L    1
  590. parm1        RS.L    1    addr of each parameter within shelline
  591. parm2        RS.L    1
  592. parm3        RS.L    1
  593. parm4        RS.L    1
  594. parm5        RS.L    1
  595. parm6        RS.L    1
  596. parm7        RS.L    1
  597. parm8        RS.L    1
  598. parm9        RS.L    1
  599. parm10        RS.B    4*16    16 extra parms
  600. endofparms    RS.L    1    for NULL end
  601.  
  602. shelline    RS.B    SHELLINE_SIZE
  603. CLIbuf        RS.B    CLIBUF_SIZE
  604. NewPrintBuffer    RS.B    NEWPRINTSIZE
  605. errorstack    RS.L    1
  606. topstack    RS.L    1
  607. stacksize    RS.L    1
  608. temp1        RS.L    1
  609. temp2        RS.L    1
  610. temp3        RS.L    1
  611. temp4        RS.L    1
  612. tempbuf        RS.B    2*SHELLINE_SIZE    double shellinesizebuffer
  613. temp2buf    RS.B    80    80 char temp buffer
  614. dosbase        RS.L    1
  615. intuibase    RS.L    1
  616. Result2        RS.L    1
  617. kickver        RS.W    1
  618. old_prompt    RS.L    1
  619. old_setname    RS.L    1
  620. old_homedir    RS.L    1
  621. redirect_in    RS.B    1
  622. redirect_out    RS.B    1
  623. CLIptr        RS.L    1
  624. Flags        RS.L    1
  625. prompt_cr    RS.L    1
  626. ConsoleSwitch    RS.L    1
  627. count_line    RS.L    1
  628. FNCignore    RS.B    30    pattern for files to ignore
  629. FNCvolume    RS.L    1    volume-ID
  630. FNCkey        RS.L    1    directory-ID
  631. FNCdate        RS.L    1    date of last change
  632. FNCsize        RS.L    1    size of buffer
  633. FNCbuffer    RS.L    1    start of buffer
  634. FNCcycle    RS.L    1    buffer pos to cycle
  635. FNCfill        RS.W    1    free bytes in buffer
  636. FNCbuffered    RS.B    1    data in buffer ?
  637. FNCchars    RS.B    1    number of chars to delete for cycle
  638. FNCback        RS.B    1    cycle backwards flag
  639. FNCnumchars    RS.B    1    number of chars in curremnt line
  640. OldCTask    RS.L    1
  641. OldCIS        RS.L    1
  642. OldCOS        RS.L    1
  643. bordersize    RS.L    1
  644. scsize        RS.L    1
  645. scaddr        RS.L    1
  646. scptr        RS.L    1
  647. scflag        RS.B    1
  648. openwin_flag    RS.B    1
  649. noresi_flag    RS.B    1
  650. noreview_flag    RS.B    1
  651. ReviewMem    RS.L    1
  652. ReviewPtr    RS.L    1
  653. ReviewSize    RS.L    1
  654. gather_ptr    RS.L    1
  655. tempbytes    RS.W    1
  656. gather        RS.B    80    for CSI string and error-string
  657. pipe_in        RS.B    14
  658. pipe_out    RS.B    14
  659. PipeTask    RS.L    1
  660. old_linhere    RS.L    1
  661. old_linmax    RS.L    1
  662. morekeys    RS.B    20
  663. dotchar        RS.B    1
  664. ctrl_codes    RS.B    29    Keyboard-CTRL-Codes
  665. CDbackstr    RS.B    80    string of last directory
  666. now        RS.L    1
  667. nost        RS.L    1
  668. then        RS.L    1
  669. past        RS.B    HISTORY_SIZE    history buffer=1024 bytes
  670. thistask    RS.L    1
  671. getmemchar    RS.L    1
  672. raw_mode    RS.L    1
  673. cursor_mode    RS.B    1
  674. x7        RS.B    5
  675. gadbase        RS.L    1
  676. MyScreen    RS.L    1
  677. VisualInfo    RS.L    1
  678. first_menudef    RS.L    1
  679. menu_count    RS.L    1
  680. first_menu    RS.L    1
  681. menu_pool    RS.L    1
  682. alias_pool    RS.L    1
  683. first_alias    RS.L    1
  684. MPipePtr    RS.L    1
  685. app_name    RS.L    1
  686. wbbase        RS.L    1
  687. copysize    RS.L    1
  688. temp5        RS.L    1
  689. temp6        RS.L    1
  690. temp7        RS.L    1
  691. appwinport    RS.L    1
  692. appwindow    RS.L    1
  693. pubscreen    RS.L    1
  694. pubname        RS.L    1
  695. windowptr    RS.L    1
  696. utilbase    RS.L    1
  697. online_help    RS.L    1
  698. windowname    RS.L    1
  699. mem_addr    RS.L    1
  700. wild_flag    RS.B    1
  701. locked_screen    RS.B    1
  702. wild_string    RS.B    80    allow 80 chars for wildcard
  703. date_mark    RS.L    3    3 lwords
  704. mem_mark    RS.L    3    3 lwords chip/fast/total
  705. CD_string    RS.B    80    Allow 80 bytes.
  706. prompt_string    RS.B    80    Allow 80 bytes.
  707. prompt_args    RS.B    40    Allow 40 bytes
  708. line_count    RS.W    1
  709. mult_comm_ptr    RS.L    1
  710. winXsize    RS.W    1
  711. winYsize    RS.W    1
  712. pipe_count    RS.B    1
  713. break_flag    RS.B    1
  714. cd_block    RS.L    1
  715. cd_volnode    RS.L    1
  716. recurs_flag    RS.W    1
  717. indent_count    RS.W    1
  718. resi_flag    RS.B    1
  719. forcediskflag    RS.B    1
  720. CLIflag        RS.B    1
  721. WBflag        RS.B    1
  722. oldwindowptr    RS.L    1
  723. wb_msg        RS.L    1
  724. iconbase    RS.L    1
  725. diskobj        RS.L    1
  726. filesys_old    RS.L    1
  727. cdir_old    RS.L    1
  728. x9        RS.B    20
  729. if_flag        RS.B    1
  730. if_condition    RS.B    1
  731. goto_flag    RS.B    1
  732. memclk_flag    RS.B    1
  733. dest_label    RS.B    60
  734. CLIbufstart    RS.L    1
  735. mem_offset_addr    RS.L    1
  736. io_Message    RS.B    20    io-request (timer)
  737. io_Device    RS.L    1
  738. io_Unit        RS.L    1
  739. io_Command    RS.W    1
  740. io_Flags    RS.B    1
  741. io_Error    RS.B    1
  742. tv_secs        RS.L    1
  743. tv_micro    RS.L    1
  744. io_pad        RS.L    2    don't remove
  745. sizeofblk    RS.W    0
  746.  
  747.  
  748.  
  749. ********************************************
  750.  
  751. ;    SECTION    MYSHELL,CODE
  752.     
  753. ;Try to open dos then do the shell
  754. start    moveq    #-1,d7
  755.     move.l    a0,a3
  756.     move.l    4.w,a6
  757.     move.l    #sizeofblk,d0
  758.     move.l    #1+1<<16,d1        "memf_public" & clear it
  759.     jsr    _LVOAllocMem(a6)    alloc general mem block
  760.     tst.l    d0
  761.     beq    blkfail
  762.     move.l    d0,a5            A5=MEMBASE
  763.     move.l    sp,topstack(a5)
  764.     move.l    a3,EntryA0(a5)
  765.     move.w    20(a6),kickver(a5)        Kickstart-Version
  766.     lea    intuiname(pc),a1
  767.     jsr    _LVOOldOpenLibrary(a6)
  768.     tst.l    d0
  769.     beq    intfail
  770.     move.l    d0,intuibase(a5)
  771.     lea    dosname(pc),a1
  772.     jsr    _LVOOldOpenLibrary(a6)
  773.     tst.l    d0
  774.     beq    dosfail
  775.     move.l    d0,dosbase(a5)
  776.     clr.w    CLIflag(a5)        delete CLI&WBflag
  777.     sub.l    a1,a1
  778.     jsr    _LVOFindTask(a6)
  779.     move.l    d0,thistask(a5)        save this task address
  780.     move.l    d0,a2
  781.     move.l    pr_CLI(a2),d0
  782.     bne.s    .A
  783.     subq.w    #1,CLIflag(a5)        WB-Start (set CLI&WBflag)
  784.     lea    pr_MsgPort(a2),a0
  785.     IFND    DEBUG
  786.     jsr    _LVOWaitPort(a6)
  787.     ENDC
  788.     IFD    DEBUG
  789.     moveq    #-1,d0
  790. .AA    move.l    #1,d1
  791.     dbra    d0,.AA
  792.     ENDC
  793.     lea    pr_MsgPort(a2),a0
  794.     jsr    _LVOGetMsg(a6)
  795.     move.l    d0,wb_msg(a5)
  796.     beq.s    .C
  797.     move.l    d0,a0
  798.     clr.l    sm_Segment(a0)        Clear Seg-Descriptor
  799. .C    move.l    pr_StackSize(a2),stacksize(a5)
  800.     move.l    pr_SegList(a2),d0
  801.     beq.s    .B
  802.     lsl.l    #2,d0
  803.     move.l    d0,a0
  804.     clr.l    12(a0)            Clear SegPointer
  805.     bra.s    .B
  806. .A    lsl.l    #2,d0            CLI-Start
  807.     move.l    d0,a2
  808.     move.l    cli_DefaultStack(a2),d0
  809.     lsl.l    #2,d0
  810.     move.l    d0,stacksize(a5)    save stacksize
  811.     clr.l    cli_Module(a2)        do not free seglist
  812.     cmp.b    #"r",1(a3)
  813.     bne.s    .B
  814.     addq.b    #1,noresi_flag(a5)
  815. .B    move.l    dosbase(a5),a6        A6=DOSBASE
  816.     tst.b    noresi_flag(a5)
  817.     bne.s    doIT
  818.     lea    ZShellName(pc),a4
  819.     bsr    search_res2
  820.     lea    start-4(pc),a1
  821.     tst.l    d0
  822.     IFD    DEBUG
  823.     bra.s    doIT
  824.     ENDC
  825.     beq.s    cresi
  826.     lsl.l    #2,d0
  827.     move.l    d0,a2
  828.     nop
  829.     nop
  830. VCheck    cmp.w    #VERSION,VCheck-start+6(a2)
  831.     bne.w    normex
  832.     addq.l    #1,resi_usecount(a0)
  833.     cmp.l    a1,a2
  834.     beq.s    doIT        running as resident
  835.     jmp    JumpIn-start+4(a2) Jump to JumpIn, but in the resident Code
  836. JumpIn    move.l    a1,d1    here it arrives
  837.     lsr.l    #2,d1
  838.     jsr    _LVOUnLoadSeg(a6)    free old mem
  839.     bra.s    doIT
  840. cresi    move.l    a1,d3
  841.     lsr.l    #2,d3
  842.     bsr    create_resi    make zshell resident
  843.     bne    crfail
  844.     addq.l    #1,resi_usecount(a2)
  845. doIT    bsr    shell            ***    DO IT    ***
  846.     bsr    KillAppWin
  847.     bsr    FreeFNC
  848.     bsr    FreeStuff
  849.     moveq    #1,d1
  850.     bsr    OutputCLInum
  851.     bsr    RemoveCLI
  852.     lea    start-4(pc),a0
  853.     move.l    a0,d6
  854.     lsr.l    #2,d6
  855.     tst.b    noresi_flag(a5)
  856.     bne.s    normex
  857.     lea    ZShellName(pc),a4
  858.     bsr    search_res2
  859.     tst.l    d0
  860.     beq.s    crfail
  861.     subq.l    #1,resi_usecount(a0)
  862.     tst.l    d7
  863.     bne.s    crfail
  864.     moveq    #1,d1
  865.     cmp.l    resi_usecount(a0),d1
  866.     bne.s    crfail
  867.     move.l    d0,d6    kill the ZShell-Resident
  868.     move.l    a0,a2
  869.     move.l    d2,a0
  870.     move.l    resi_link(a2),resi_link(a0)
  871.     clr.l    resi_link(a2)
  872.     move.l    a2,d1
  873.     lsr.l    #2,d1
  874.     jsr    _LVOUnLoadSeg(a6)
  875. normex    bsr    closelog    close logfile
  876.     bsr    giveman        free manualmem
  877.     move.l    thistask(a5),a0
  878.     tst.b    CLIflag(a5)    How to UnLoad the Segment
  879.     beq.s    .A
  880.     move.l    pr_SegList(a0),d0
  881.     beq.s    .B
  882.     lsl.l    #2,d0
  883.     move.l    d0,a0
  884.     move.l    d6,12(a0)    Store Segment in SegPointer (WB/RUN)
  885. .B    move.l    wb_msg(a5),d0
  886.     beq.s    crfail
  887.     move.l    d0,a0
  888.     move.l    d6,sm_Segment(a0)    and in Seg-Descriptor    (WB)
  889.     bra.s    crfail
  890. .A    move.l    pr_CLI(a0),a0
  891.     add.l    a0,a0
  892.     add.l    a0,a0
  893.     move.l    d6,cli_Module(a0)    Store Segment in Module    (CLI)
  894. crfail    move.l    dosbase(a5),a1
  895.     move.l    4.w,a6
  896.     jsr    _LVOCloseLibrary(a6)
  897. dosfail    move.l    intuibase(a5),a1
  898.     jsr    _LVOCloseLibrary(a6)
  899. intfail    move.l    wb_msg(a5),d2
  900.     move.l    a5,a1
  901.     move.l    #sizeofblk,d0
  902.     jsr    _LVOFreeMem(a6)
  903.     tst.l    d2
  904.     beq.s    .A
  905.     jsr    _LVOForbid(a6)    (what for ?)
  906.     move.l    d2,a1        WB-Message
  907.     jmp    _LVOReplyMsg(a6)    never returns !
  908. .A    moveq    #0,d0
  909.     rts
  910. blkfail    moveq    #RETURN_ERROR,d0
  911.     rts
  912.  
  913. *********************************
  914. *    MAIN BIT        *
  915. *********************************
  916. shell    move.l    sp,errorstack(a5)
  917.     IFD    KILL
  918.     cmp.w    #36,kickver(a5)
  919.     blo.s    .D
  920.     move.l    thistask(a5),a3
  921.     lea    CleanUp(pc),a0
  922.     move.l    a0,pr_ExitCode(a3)
  923.     move.l    a5,pr_ExitData(a3)
  924. .D    ENDC
  925.     move.l    4.w,a6
  926.     lea    utilname(pc),a1    open utility.library
  927.     moveq    #37,d0
  928.     jsr    _LVOOpenLibrary(a6)
  929.     move.l    d0,utilbase(a5)
  930.     move.l    dosbase(a5),a6
  931.     move.l    #%11111001010,d0
  932.     bsr    SetFlags
  933.     bsr    CreateCLI
  934.     bne    ExitZShell        exit on error
  935.     move.l    thistask(a5),a3
  936.     move.l    pr_CLI(a3),a2
  937.     add.l    a2,a2
  938.     add.l    a2,a2
  939.     move.l    a2,CLIptr(a5)
  940.     move.l    cli_Prompt(a2),old_prompt(a5)    save prompt
  941.     lea    prompt_args(a5),a0
  942.     move.l    a0,d0
  943.     lsr.l    #2,d0
  944.     move.l    d0,cli_Prompt(a2)
  945.     move.l    cli_SetName(a2),old_setname(a5)    save current dir name
  946.     lea    CD_string(a5),a0
  947.     move.l    a0,d0
  948.     lsr.l    #2,d0
  949.     move.l    d0,cli_SetName(a2)
  950.     bsr    SetConHandles
  951.     cmp.w    #36,kickver(a5)        OS2 ?
  952.     blo.s    .C
  953.     move.l    pr_HomeDir(a3),old_homedir(a5)    save PROGDIR:
  954.     clr.l    pr_HomeDir(a3)
  955.     move.l    dl_Root(a6),a0
  956.     bset    #0,rn_Flags(a0)    set wildstar flag (bit 24)
  957.     bsr    InitAppWin
  958.     tst.l    pr_CES(a3)
  959.     bne.s    .C
  960.     jsr    _LVOOutput(a6)
  961.     move.l    d0,pr_CES(a3)        set error output handle
  962. .C    tst.b    WBflag(a5)
  963.     bne.s    notini        0=WB/1=newcli/2=run/3=pipe
  964.     bsr    initialise_default    initialize other stuff
  965. notini    moveq    #0,d1
  966.     bsr    OutputCLInum
  967.     tst.b    CLIflag(a5)
  968.     beq.s    .A
  969.     cmp.b    #2,WBflag(a5)
  970.     bhs.s    .A
  971.     moveq    #-127,d0
  972.     subq.l    #2,d0
  973.     bsr    GetMessage    Welcome-Message
  974.     lea    pr_TaskNum(a3),a1
  975.     bsr    new_print
  976. .A    bsr    eval_CD
  977.     IFND    DEBUG
  978.     bsr    execscr        execute startup script
  979.     ENDC
  980. chorus    bsr    CheckForbid    HERE BEGINS THE MAIN LOOP
  981.     bsr    close_redirection
  982.     bsr    pr_show_cursor    make sure cursor is visible
  983.     bsr    raw_off        and raw mode is off
  984.     clr.b    noreview_flag(a5)    and review is enabled
  985.     bsr    compose_prompt
  986.     bsr    get_line
  987.     clr.b    break_flag(a5)
  988.     move.l    4.w,a6
  989.     moveq    #0,d0        clear signals c&d
  990.     moveq    #0,d1
  991.     bset    #SIGBREAKB_CTRL_C,d1
  992.     bset    #SIGBREAKB_CTRL_D,d1
  993.     jsr    _LVOSetSignal(a6)
  994.     move.l    dosbase(a5),a6
  995.     clr.b    forcediskflag(a5)
  996.     move.l    parm1(a5),a0
  997.     move.b    (a0),d0
  998.     cmp.b    dotchar(a5),d0
  999.     bne.s    .A
  1000.     addq.l    #1,a0
  1001.     tst.b    (a0)
  1002.     bne.s    .B
  1003.     lea    CDbackstr(a5),a0    dir back
  1004.     bsr    chdir
  1005.     bra.s    chorus
  1006. .B    move.l    a0,parm1(a5)
  1007.     addq.b    #1,forcediskflag(a5)
  1008.     bra    notfound    force disk-command
  1009. .A    cmp.b    #"#",(a0)    #-sign for ;#comment
  1010.     beq    chorus
  1011.     moveq    #0,d7
  1012.     move.b    #"?",d0        check for ? (help sign)
  1013.     bsr    CheckOneChar
  1014.     bne.s    .C
  1015.     bsr    help_man    ? as command
  1016.     bra    chorus
  1017. .C    bsr    matchcmd        offset to d2.w
  1018.     beq.s    notfound
  1019.     move.l    parm1(a5),d7        check for ? (help sign)
  1020.     move.l    parm2(a5),d0
  1021.     beq.s    .D
  1022.     move.l    d0,a0
  1023.     move.b    #"?",d0
  1024.     bsr    CheckOneChar
  1025.     bne.s    .D
  1026.     bsr    help_man    ? as arg
  1027.     bra    chorus
  1028. .D    move.l    sp,errorstack(a5)    important in scripts ?
  1029.     lea    cmdstart(pc),a0
  1030. intern    jsr    0(a0,d2.w)    call internal command
  1031.     tst.b    break_flag(a5)
  1032.     bne.s    com_break
  1033. chkfail    move.l    d0,last_failcode(a5)
  1034.     move.l    CLIptr(a5),a0
  1035.     cmp.l    cli_FailLevel(a0),d0    ALL COMMANDS MUST RETURN D0=0 unless failure
  1036.     blo    chorus
  1037. com_fail move.l    d0,-(sp)
  1038.     bsr    close_redirection    additional for pipes
  1039.     move.l    #-154,d0
  1040.     bsr    GetMessage        Fail Level
  1041.     move.l    sp,a1
  1042.     bsr    new_print
  1043.     move.l    (sp)+,d0
  1044. com_break bsr    kill_script
  1045.     bra    chorus
  1046. notfound bsr    archie3        TRY DISK
  1047.     move.l    d0,-(sp)
  1048.     move.l    thistask(a5),a0
  1049.     move.l    cd_volnode(a5),d0
  1050.     move.l    pr_CurrentDir(a0),a1
  1051.     add.l    a1,a1
  1052.     add.l    a1,a1
  1053.     cmp.l    fl_Volume(a1),d0    check volume node
  1054.     bne.s    .A
  1055.     move.l    cd_block(a5),d0
  1056.     cmp.l    fl_Key(a1),d0    check disk block number
  1057.     beq.s    .B
  1058. .A    bsr    eval_CD        If command changes cd then change prompt.
  1059. .B    move.l    (sp)+,d0
  1060.     bra.s    chkfail
  1061.  
  1062.     
  1063. *********************************************
  1064.  
  1065. ZShellName    dc.b    "ZShell",0
  1066. dosname        dc.b    "dos.library",0
  1067. intuiname    dc.b    "intuition.library",0
  1068. utilname    dc.b    "utility.library",0
  1069.  
  1070. end_tx        dc.b    " end",0
  1071. askforsize    dc.b    $9b," q",0
  1072.  
  1073. helpld    dc.b    "Loading "
  1074. helpman    dc.b    "ZShell.doc",0
  1075. helpmor    dc.b    13,$9b,"32m %d%% %ld bytes. Use: (shift+)cursor,"
  1076.     dc.b    "(back)space,numeric,s,n,j,w,r,h",$9b,"K",$9b,"m",0
  1077.  
  1078. ctrl_init    dc.b    46,23,17,19,5,9,24,27,20,25,8,10,13,12,18,22,6,16
  1079. ctrl_inite        ;CTRL-Codes
  1080. more_init    dc.b    "ABCDSTqsnjwrh"    MORE keys
  1081. more_inite
  1082.  
  1083.     dc.b    "$VER: "
  1084. helptx1 dc.b    "ZShell 2.8 (10-Sep-95)",10
  1085.     dc.b    "(C)1990,91 Paul Hayter (V1.3); "
  1086.     dc.b    "Updated 1993-95 by Martin Gierich.",10
  1087.     dc.b    "Freeware, NO commercial usage !",10
  1088.     dc.b    "Please send your comments to"
  1089.     dc.b    " uj3w@rz.uni-karlsruhe.de",10,10
  1090.     dc.b    "Commands:",0
  1091. helptx2 dc.b    "Options:",10
  1092.     dc.b    "-r (recursive): Copy,Delete,Dir,Join,List,Move,Protect",10
  1093.     dc.b    "-c (clear): Avail,Endcli,Locate,Path,Resident",10
  1094.     dc.b    "-q (quick): Dir,List,Delete",10,10
  1095.     dc.b    "Editing: (SHIFT+) Cursor, <-, DEL,"
  1096.     dc.b    " (SHIFT+) TAB, ESC and see CONFIG CTRLKEYS",10
  1097.     dc.b    ". for dir back, force disk or abbreviation",10
  1098.     dc.b    "Type 'help ?' for more help.",0
  1099. helptx3    even
  1100.  
  1101. **********************************************************
  1102.  
  1103. initialise_default
  1104.     move.l    CLIptr(a5),a0
  1105.     moveq    #16,d0
  1106.     move.l    d0,cli_FailLevel(a0)
  1107.     move.b    #LF,past(a5)
  1108.     lea    prompt_args_tx(pc),a0    init prompt
  1109.     lea    prompt_args(a5),a1
  1110. .C    move.b    (a0)+,(a1)+
  1111.     bne.s    .C
  1112.     moveq    #ctrl_inite-ctrl_init-1,d0
  1113.     lea    ctrl_init(pc),a0
  1114.     lea    ctrl_codes-1(a5),a1
  1115. .B    move.b    (a0)+,(a1)+        init ctrl-codes and dotchar
  1116.     dbra    d0,.B
  1117.     moveq    #more_inite-more_init-1,d0
  1118.     lea    more_init(pc),a0
  1119.     lea    morekeys(a5),a1
  1120. .A    move.b    (a0)+,(a1)+        init keys for MORE
  1121.     dbra    d0,.A
  1122.     lea    appicontx(pc),a0
  1123.     move.l    a0,app_name(a5)
  1124.     lea    helpman(pc),a0
  1125.     move.l    a0,online_help(a5)
  1126.     move.l    #50000,copysize(a5)
  1127.     move.l    #4000,FNCsize(a5)
  1128.     rts
  1129.  
  1130. SetConHandles
  1131.     jsr    _LVOOutput(a6)    SAVE THE CONSOLE HANDLERS
  1132.     move.l    d0,outhandle(a5)
  1133.     move.l    d0,stdout(a5)
  1134.     jsr    _LVOInput(a6)
  1135.     move.l    d0,inhandle(a5)
  1136.     move.l    d0,stdin(a5)
  1137.     rts
  1138.  
  1139. CheckOneChar    ;d0=char to check in a0=parm
  1140.     move.b    (a0),d1
  1141.     bsr    compD1D0nocase
  1142.     bne.s    .A
  1143.     tst.b    1(a0)
  1144.     bne.s    .A
  1145.     cmp.b    #$22,-1(a0)
  1146.     beq.s    .A
  1147.     moveq    #0,d0
  1148.     rts
  1149. .A    moveq    #1,d0
  1150.     rts
  1151.  
  1152. OutputCLInum        ;ENTRY: d1=0:start, d1=1:end
  1153.     btst    #FLdebug,Flags+3(a5)
  1154.     beq.s    .A
  1155.     lea    tempbuf(a5),a1
  1156.     bsr.s    InsertCLInum
  1157.     tst.l    d1
  1158.     beq.s    .B
  1159.     lea    end_tx(pc),a2
  1160. .C    move.b    (a2)+,(a1)+
  1161.     bne.s    .C
  1162.     subq.l    #1,a1
  1163. .B    move.b    #LF,(a1)+
  1164.     clr.b    (a1)
  1165.     lea    tempbuf(a5),a1
  1166.     bsr    pr_error
  1167. .A    rts
  1168.  
  1169. InsertCLInum        ;string in a1
  1170.     lea    ZShellName(pc),a2
  1171. .B    move.b    (a2)+,(a1)+    append "ZShell"
  1172.     bne.s    .B
  1173.     subq.l    #1,a1
  1174. InsertCLInum2
  1175.     move.l    thistask(a5),a2
  1176.     move.l    pr_TaskNum(a2),d0
  1177.     bra    qpr10        append CLI number
  1178.  
  1179. InitAppWin
  1180.     btst    #FLraw,Flags+2(a5)    test raw-mode
  1181.     beq.s    .A
  1182.     move.l    4.w,a6
  1183.     jsr    _LVOCreateMsgPort(a6)    get MsgPort
  1184.     move.l    d0,appwinport(a5)
  1185.     beq.s    .A
  1186.     move.l    d0,a2
  1187.     move.l    dosbase(a5),a6
  1188.     move.l    windowptr(a5),d2    get ptr to window
  1189.     beq.s    .A
  1190.     bsr    OpenWBLib
  1191.     beq    .A
  1192.     moveq    #0,d0
  1193.     moveq    #0,d1
  1194.     move.l    d2,a0
  1195.     sub.l    a1,a1
  1196.     exg.l    a1,a2
  1197.     jsr    _LVOAddAppWindowA(a6)    make AppWin
  1198.     move.l    d0,appwindow(a5)
  1199. .A    move.l    dosbase(a5),a6
  1200.     rts
  1201.  
  1202. KillAppWin
  1203.     move.l    appwindow(a5),d2
  1204.     beq.s    .B
  1205.     bsr    OpenWBLib
  1206.     move.l    d2,a0
  1207.     jsr    _LVORemoveAppWindow(a6)    remove AppWin
  1208.     clr.l    appwindow(a5)
  1209. .B    move.l    appwinport(a5),d0
  1210.     beq.s    .A
  1211.     move.l    d0,a0
  1212.     move.l    4.w,a6
  1213.     jsr    _LVODeleteMsgPort(a6)    remove MsgPort
  1214.     clr.l    appwinport(a5)
  1215. .A    move.l    dosbase(a5),a6
  1216.     rts
  1217.  
  1218. GetWindowPtr    ;pointer to Console-Window to d0 (0 for fail)
  1219.     move.l    thistask(a5),a0
  1220.     move.l    pr_ConsoleTask(a0),d0
  1221.     move.l    d0,packettask(a5)
  1222.     beq.s    .A
  1223.     bsr    GetDiskInfo
  1224.     beq.s    .A
  1225.     moveq    #0,d0
  1226.     tst.l    sp_res1(a5)
  1227.     beq.s    .A
  1228.     move.l    id_VolumeNode(a5),d0    it is in here !
  1229.     beq.s    .A
  1230.     move.l    d0,windowptr(a5)
  1231.     move.l    thistask(a5),a0
  1232.     move.l    d0,pr_WindowPtr(a0)
  1233. .A    rts
  1234.  
  1235. GetWinSize    ;Get dimensions of current output console
  1236.     movem.l    d2/d3/a2,-(sp)
  1237.     move.l    outhandle(a5),d1
  1238.     beq.s    .H
  1239.     jsr    _LVOIsInteractive(a6)
  1240.     tst.l    d0
  1241.     beq.s    .H
  1242.     lea    askforsize(pc),a1
  1243.     bsr    pr_string
  1244.     move.l    outhandle(a5),d1
  1245.     lea    NewPrintBuffer(a5),a2
  1246.     move.l    a2,d2
  1247.     moveq    #100,d3
  1248.     jsr    _LVORead(a6)    get size of window
  1249.     move.l    a2,a0
  1250.     add.l    d0,a2
  1251. .B    cmp.l    a0,a2
  1252.     bls.s    .H
  1253.     cmp.b    #"r",-(a2)
  1254.     bne.s    .B
  1255.     cmp.b    #" ",-(a2)
  1256.     bne.s    .B
  1257.     moveq    #1,d1
  1258. .C    cmp.b    #";",-(a2)
  1259.     bne.s    .C
  1260.     dbra    d1,.C
  1261.     addq.l    #1,a2
  1262.     move.l    a2,a1
  1263.     bsr    convert_ASCII_to_num
  1264.     move.w    d0,winYsize(a5)
  1265.     bsr    convert_ASCII_to_num
  1266.     move.w    d0,winXsize(a5)
  1267. .H    move.w    winYsize(a5),d0
  1268.     bne.s    .A
  1269.     moveq    #18,d0
  1270. .A    movem.l    (sp)+,d2/d3/a2
  1271.     rts
  1272.  
  1273. dec2asc    ext.l    d0    put decimal number in D0.w to string in A0
  1274.     move.l    #10000,d1
  1275. .C    divu    d1,d0
  1276.     bne.s    .E
  1277.     divu    #10,d1
  1278.     beq.s    .A
  1279.     swap    d0
  1280.     bne.s    .C
  1281. .D    divu    d1,d0
  1282. .E    add.b    #"0",d0
  1283.     move.b    d0,(a0)+
  1284.     swap    d0
  1285.     ext.l    d0
  1286.     divu    #10,d1
  1287.     bne.s    .D
  1288. .A    rts
  1289.  
  1290.  
  1291. *CHECK WHETHER A SCRIPT NAME WAS TYPED ON ENTRY TO ZSHELL
  1292. execscr    move.l    EntryA0(a5),d0
  1293.     move.l    d0,parm1(a5)
  1294.     beq.s    .C
  1295.     move.l    d0,a0
  1296.     tst.b    (a0)
  1297.     bne    xz2    ;NB this is OK, xz2 will pop the return addr 
  1298.             ;and jump to chorus
  1299.     rts
  1300. .C            ;handle DEFAULT SCRIPT FILE s:zstart
  1301.     bsr    RequestersOff    disable volume requesters
  1302.     lea    defscript(pc),a2
  1303.     move.l    a2,d1
  1304.     moveq    #ACCESS_READ,d2
  1305.     jsr    _LVOLock(a6)
  1306.     bsr    RequestersOn
  1307.     move.l    d0,d1    test lock
  1308.     beq.s    .B
  1309.     jsr    _LVOUnLock(a6)
  1310.     move.l    a2,a0
  1311.     bra    xz2
  1312. .B    rts
  1313.  
  1314. CheckForbid
  1315.     move.l    4.w,a0        Check for not closed
  1316.     moveq    #-1,d0
  1317.     cmp.b    294(a0),d0    Disables or
  1318.     bne.s    .A
  1319.     cmp.b    295(a0),d0    Forbids
  1320.     beq.s    .B
  1321. .A    move.b    d0,294(a0)    and avoids crashes !
  1322.     move.b    d0,295(a0)
  1323.     moveq    #22,d1
  1324.     bsr    GuruIt
  1325. .B    rts
  1326.  
  1327.     IFD    KILL
  1328. CleanUp    movem.l    d0-d7/a0-a6,-(sp)
  1329.     move.l    d1,a5
  1330.     bsr    DisplayBeep
  1331.     move.l    thistask(a5),a3
  1332.     clr.l    pr_ExitCode(a3)
  1333.     movem.l    (sp)+,d0-d7/a0-a6
  1334.     rts
  1335.     ENDC
  1336.  
  1337. **********************************************************
  1338. FreeFNC    move.l    FNCbuffer(a5),d0
  1339.     beq.s    .A
  1340.     move.l    d0,a1
  1341.     move.l    FNCsize(a5),d0
  1342.     bsr    givemem
  1343. .A    clr.l    FNCbuffer(a5)
  1344. FlushFNC
  1345.     clr.l    FNCcycle(a5)
  1346.     clr.w    FNCfill(a5)
  1347.     clr.b    FNCbuffered(a5)
  1348.     rts
  1349.  
  1350. * Subroutine for name2complete, limiting chars: : / " ; | and space
  1351. cjk1    subq.l    #1,a1
  1352.     cmp.b    #":",(a1)
  1353.     beq.s    cjke
  1354.     cmp.b    #"/",(a1)
  1355.     beq.s    cjke
  1356. cjk2    cmp.b    #$22,(a1)
  1357.     beq.s    cjke
  1358.     cmp.b    #" ",(a1)
  1359.     beq.s    cjke
  1360.     cmp.b    #";",(a1)
  1361.     beq.s    cjke
  1362.     cmp.b    #"|",(a1)
  1363. cjke    addq.l    #1,a1
  1364.     rts
  1365.  
  1366. name2complete    ;used by complet and CTRL-F
  1367.     lea    shelline(a5),a1
  1368.     move.l    a1,a0
  1369.     move.l    d5,d6
  1370.     beq.s    .B
  1371.     add.l    d5,a1
  1372.     bsr    cjk1
  1373.     beq.s    .B
  1374. .A    subq.l    #1,a1        look for begin of filename
  1375.     cmp.l    a1,a0
  1376.     beq.s    .B    
  1377.     bsr    cjk1
  1378.     bne.s    .A
  1379. .B    move.l    a1,a2        filename-pos. in a2
  1380.     sub.l    a0,a1
  1381.     sub.l    a1,d6        length in d6
  1382.     move.b    (a2),d3        save char in d3
  1383.     tst.l    FNCcycle(a5)
  1384.     bne.s    .I
  1385.     lea    0(a2,d6.l),a3
  1386.     move.b    (a3),d2
  1387.     clr.b    (a3)
  1388.     move.l    a0,-(sp)
  1389.     move.l    a2,a0
  1390.     bsr    handle_wild_dirs    check for wild cards
  1391.     move.l    (sp)+,a0
  1392.     move.b    d2,(a3)
  1393. .I    clr.b    (a2)        null-end pathname
  1394.     move.l    a2,a1
  1395.     bra.s    .F
  1396. .D    subq.l    #1,a1        look for begin of path
  1397. .F    cmp.l    a1,a0
  1398.     beq.s    .E
  1399.     subq.l    #1,a1
  1400.     bsr    cjk2
  1401.     bne.s    .D
  1402. .E    rts
  1403.  
  1404. * Complete Filename in Shelline *
  1405. * INTERNAL: a2 points to part of filename, d6 length of part *
  1406. * ENTRY: d4: linmax , d5:linhere *
  1407. complet    tst.l    FNCcycle(a5)
  1408.     beq.s    .C
  1409.     moveq    #0,d0
  1410.     move.b    FNCchars(a5),d0
  1411.     sub.l    d0,d5        delete some chars for cycling
  1412.     bsr    delete_in_mem
  1413. .C    clr.b    temp2buf(a5)
  1414.     bsr    name2complete
  1415.     move.l    a1,d1
  1416.     moveq    #-2,d2
  1417.     jsr    _LVOLock(a6)    lock path
  1418.     move.b    d3,(a2)        replace null-char by old one
  1419.     move.l    d0,d7        save lock
  1420.     beq    DisplayBeep
  1421.     bsr    fibexam2
  1422.     moveq    #0,d3
  1423.     tst.l    fib_DirEntryType(a5)
  1424.     bpl.s    cplbuf        if plus,is directory
  1425. cplunlk    move.l    d7,d1
  1426.     jsr    _LVOUnLock(a6)
  1427.     rts            an error occured
  1428.  
  1429. cplbuf    move.l    FNCbuffer(a5),d0    create and init FNC buffer
  1430.     bne.s    .A
  1431.     move.l    FNCsize(a5),d0
  1432.     bsr    iwantmem
  1433.     beq.s    wdhcpl
  1434.     move.l    d0,FNCbuffer(a5)
  1435. .A    move.l    FNCcycle(a5),d1
  1436.     beq.s    .B
  1437.     move.l    d1,d0
  1438. .B    move.l    d0,a4
  1439.     move.b    #1,FNCbuffered(a5)
  1440.     move.l    d7,d0
  1441.     lsl.l    #2,d0
  1442.     move.l    d0,a1
  1443.     move.l    fl_Volume(a1),d0
  1444.     move.l    fl_Key(a1),d1
  1445.     lea    fib_Date(a5),a0
  1446.     move.l    (a0)+,d2
  1447.     add.l    (a0)+,d2
  1448.     add.l    (a0)+,d2
  1449.     tst.w    FNCfill(a5)
  1450.     beq.s    .C
  1451.     cmp.l    FNCvolume(a5),d0    check volume node
  1452.     bne.s    .C
  1453.     cmp.l    FNCkey(a5),d1        check disk block number
  1454.     bne.s    .C
  1455.     cmp.l    FNCdate(a5),d2        check date of last change
  1456.     beq.s    wdhcpl
  1457. .C    move.l    d0,FNCvolume(a5)
  1458.     move.l    d1,FNCkey(a5)
  1459.     move.l    d2,FNCdate(a5)
  1460.     move.l    FNCbuffer(a5),a4
  1461.     clr.l    FNCcycle(a5)
  1462.     clr.b    FNCbuffered(a5)
  1463.     clr.b    (a4)+
  1464.     move.l    FNCsize(a5),d0
  1465.     subq.l    #2,d0
  1466.     move.w    d0,FNCfill(a5)
  1467.  
  1468. wdhcpl    tst.b    FNCbuffered(a5)
  1469.     bne.s    cplbuffered
  1470.     bsr    fibexnx        not buffered: get next filename from dir
  1471.     tst.l    d0        next filename or dirname
  1472.     beq    endcpl
  1473. ;    lea    fib_FileName(a5),a0
  1474.     bsr    ignorematch    wildcheck for names to ignore
  1475.     beq.s    wdhcpl
  1476. ;    lea    fib_FileName(a5),a0
  1477.     lea    tempbuf(a5),a1    store filename in tempbuf
  1478.     move.l    a1,a3
  1479. .B    tst.w    FNCfill(a5)
  1480.     bne.s    .D
  1481.     move.b    (a0)+,(a1)+    buffer already full: only copy name
  1482.     bne.s    .B
  1483.     bra.s    .F
  1484. .D    subq.w    #1,FNCfill(a5)
  1485.     move.b    (a0),(a1)+    copy name
  1486.     move.b    (a0)+,(a4)+    store filename to buffer
  1487.     bne.s    .B
  1488. .F    moveq    #" ",d0        add a space at the end of files
  1489.     tst.l    fib_DirEntryType(a5)
  1490.     bmi.s    .G        if plus,is directory
  1491.     moveq    #"/",d0        add a / at the end of dirs
  1492. .G    move.b    d0,-1(a1)
  1493.     clr.b    (a1)        null-end
  1494.     tst.w    FNCfill(a5)
  1495.     beq.s    .E
  1496.     subq.w    #1,FNCfill(a5)    if buffer not full: do same with buffer
  1497.     move.b    d0,-1(a4)
  1498.     clr.b    (a4)+
  1499. .E    bra.s    wd2cpl
  1500.  
  1501. cplbuffered
  1502.     tst.b    FNCback(a5)    cycle back ?
  1503.     beq.s    .A
  1504. .D    subq.l    #1,a4
  1505.     cmp.l    FNCbuffer(a5),a4    yes: check for begin of buffer
  1506.     bls.s    .E
  1507.     tst.b    -1(a4)        look for begin of previous name
  1508.     bne.s    .D
  1509.     bra.s    .C
  1510. .E    move.l    FNCbuffer(a5),a4    look for end of buffer
  1511. .F    tst.b    (a4)+
  1512.     bne.s    .F
  1513.     tst.b    (a4)
  1514.     bne.s    .F
  1515.     bra.s    .D
  1516.  
  1517. .A    tst.b    (a4)+        was buffered: skip to next name
  1518.     bne.s    .A
  1519.     tst.b    (a4)        test for end of buffer
  1520.     bne.s    .C
  1521.     tst.l    FNCcycle(a5)
  1522.     beq    endcpl
  1523.     move.l    FNCbuffer(a5),a4    end of buffer: set at begin
  1524.     addq.l    #1,a4        skip first null-byte
  1525. .C    move.l    a4,a3
  1526.  
  1527. wd2cpl    move.l    a3,a0
  1528.     tst.b    wild_flag(a5)
  1529.     beq.s    .F
  1530. .B    tst.b    (a3)+
  1531.     bne.s    .B
  1532.     subq    #2,a3
  1533.     move.b    (a3),d2        save last char
  1534.     clr.b    (a3)        clear space or /
  1535.     bsr    wildmatcher    check wildcards
  1536.     move.b    d2,(a3)
  1537.     move.l    a0,a3
  1538.     tst.l    d0
  1539.     bne    wdhcpl
  1540.     bra.s    .H        do not check for matching parts
  1541. .F    move.l    a2,a1
  1542.     move.l    d6,d2
  1543.     move.l    utilbase(a5),d0
  1544.     beq.s    .D
  1545.     move.l    d0,a6
  1546.     move.l    d2,d0
  1547.     jsr    _LVOStrnicmp(a6)    OS2+ does it match to part ?
  1548.     move.l    dosbase(a5),a6
  1549.     tst.l    d0
  1550.     bne    wdhcpl
  1551.     bra.s    .H
  1552. .A    move.b    (a0)+,d0
  1553.     move.b    (a1)+,d1
  1554.     bsr    compD1D0nocase        does it match to part ?
  1555.     bne    wdhcpl
  1556. .D    dbra    d2,.A
  1557. .H    tst.l    d3
  1558.     bne.s    wd3cpl
  1559.     moveq    #-1,d0        ! first time: copy filename !
  1560.     lea    temp2buf(a5),a0
  1561. .C    addq.l    #1,d0
  1562.     move.b    (a3)+,(a0)+
  1563.     bne.s    .C
  1564.     moveq    #1,d3
  1565.     tst.l    FNCcycle(a5)
  1566.     beq    wdhcpl
  1567.     sub.l    d6,d0
  1568.     move.b    d0,FNCchars(a5)    chars more than given part of name
  1569.     move.l    a4,FNCcycle(a5)    position of next name to FNCcycle
  1570.     bra    endcpl
  1571.  
  1572. wd3cpl    tst.l    d3        ! next time !
  1573.     bmi.s    .E
  1574.     moveq    #-1,d3
  1575.     btst    #FLmatch,Flags+3(a5)
  1576.     beq.s    .E
  1577.     btst    #FLhide,Flags+2(a5)
  1578.     beq.s    .H
  1579.     bsr    pr_hide_cursor
  1580.     bsr    GetWinSize
  1581. .H    bsr    pr_lf
  1582.     lea    temp2buf(a5),a1    print first time
  1583.     move.l    a1,a0
  1584.     moveq    #-1,d0
  1585. .C    addq.l    #1,d0
  1586.     tst.b    (a0)+
  1587.     bne.s    .C
  1588.     move.b    d0,FNCnumchars(a5)
  1589.     bsr    pr_string
  1590.     bsr    pr_space
  1591. .E    move.l    a3,a1
  1592.     lea    temp2buf(a5),a0
  1593. .G    move.b    (a0)+,d0
  1594.     move.b    (a1)+,d1
  1595.     bsr    compD1D0locale    next time: find longest common part
  1596.     bne.s    .D
  1597.     tst.b    -1(a0)
  1598.     beq.s    .D
  1599.     tst.b    -1(a1)
  1600.     bne.s    .G
  1601. .D    clr.b    -1(a0)
  1602.     btst    #FLmatch,Flags+3(a5)
  1603.     beq    wdhcpl
  1604.     lea    NewPrintBuffer(a5),a0
  1605.     moveq    #0,d0
  1606. .A    addq.l    #1,d0
  1607.     move.b    (a3)+,(a0)+
  1608.     bne.s    .A
  1609.     move.b    #" ",-1(a0)
  1610.     clr.b    (a0)
  1611.     move.l    d0,d1
  1612.     tst.w    winXsize(a5)
  1613.     beq.s    .F
  1614.     add.b    FNCnumchars(a5),d1
  1615.     cmp.w    winXsize(a5),d1
  1616.     blo.s    .F
  1617.     move.l    d0,d1
  1618.     bsr    pr_lf
  1619. .F    move.b    d1,FNCnumchars(a5)
  1620.     lea    NewPrintBuffer(a5),a1
  1621.     bsr    pr_string    print other times
  1622.     bra    wdhcpl        repeat with all filenames
  1623.  
  1624. endcpl    tst.b    FNCbuffered(a5)
  1625.     bne.s    .A
  1626.     clr.b    (a4)        end buffer with 0
  1627. .A    move.l    d7,d1
  1628.     jsr    _LVOUnLock(a6)
  1629.     tst.l    d3
  1630.     beq    DisplayBeep
  1631.     bpl.s    .D        enable cycling if multiple matches found
  1632.     move.l    FNCbuffer(a5),FNCcycle(a5)
  1633.     clr.b    FNCchars(a5)
  1634.     btst    #FLmatch,Flags+3(a5)
  1635.     beq    .B
  1636.     lea    farb3(pc),a1
  1637.     bsr    pr_stringlf
  1638.     move.l    prompt_cr(a5),a1
  1639.     bsr    pr_string
  1640.     bsr    gimme2        print shelline again
  1641. .B    tst.b    wild_flag(a5)
  1642.     beq.s    .D
  1643.     move.b    d6,FNCchars(a5)
  1644.     rts
  1645. .D    lea    temp2buf(a5),a1
  1646.     move.l    d6,d2
  1647.     bra.s    insert_string2    insert new stuff in shelline
  1648.  
  1649. insert_string    ;insert string in a1 into shelline
  1650.     moveq    #0,d2
  1651. insert_string2    ;d2=number of chars before current pos
  1652.     moveq    #-1,d1
  1653. .G    addq.l    #1,d1        D1=length
  1654.     tst.b    (a1)+
  1655.     bne.s    .G
  1656.     sub.l    d2,d1
  1657.     bpl.s    .B
  1658.     move.l    d1,d0        calc chars to backspace
  1659.     neg.l    d0
  1660.     sub.l    d0,d2
  1661.     move.l    a1,-(sp)
  1662.     sub.l    d0,d5
  1663.     bsr    delete_in_mem    string to overwrite was longer
  1664.     move.l    (sp)+,a1
  1665.     moveq    #0,d1
  1666. .B    subq.l    #1,a1        for later
  1667.     move.l    d4,d0
  1668.     add.l    d1,d0
  1669.     cmp.w    #SHELLINE_SIZE-2,d0    make sure line is not too long
  1670.     blo.s    .E
  1671.     bsr    DisplayBeep
  1672.     bra    gimme3
  1673. .E    movem.l    a2-a3,-(sp)
  1674.     lea    shelline(a5),a0    ethel
  1675.     lea    1(a0,d4.w),a3    A3=linmax
  1676.     move.l    a3,a2
  1677.     add.l    d1,a2        A2=linmax+length
  1678.     lea    0(a0,d5.w),a0    linhere
  1679. .A    move.b    -(a3),-(a2)    insert chars into shelline
  1680.     cmp.l    a3,a0
  1681.     bne.s    .A
  1682.     move.l    d1,d0
  1683.     add.l    d2,d0
  1684.     bra.s    .C
  1685. .D    move.b    -(a1),-(a2)    copy found filename
  1686. .C    dbra    d0,.D
  1687.     movem.l    (sp)+,a2-a3
  1688.     add.l    d1,d5
  1689.     add.l    d1,d4
  1690. .F    bra    gimme3        print shelline
  1691.  
  1692. DisplayBeep
  1693.     move.l    intuibase(a5),a6
  1694.     suba.l    a0,a0
  1695.     jsr    _LVODisplayBeep(a6)
  1696.     move.l    dosbase(a5),a6
  1697.     rts
  1698.  
  1699. **********    END OF FNC    ***********
  1700.  
  1701.  
  1702. get_one_char    ;read one char from keyboard to d6, process AppWindow
  1703.     move.l    getmemchar(a5),d0
  1704.     beq.s    .G
  1705.     addq.l    #1,getmemchar(a5)
  1706.     move.l    d0,a0
  1707.     move.b    (a0),d6        get char from memory (for function keys)
  1708.     beq.s    .H
  1709.     rts
  1710. .H    clr.l    getmemchar(a5)    end of memchar buffer
  1711. .G    bsr    clearArgs
  1712.     move.l    inhandle(a5),myArg1(a5)
  1713.     lea    tempbytes(a5),a0
  1714.     move.l    a0,myArg2(a5)
  1715.     moveq    #1,d0
  1716.     move.l    d0,myArg3(a5)
  1717.     move.l    thistask(a5),a0
  1718.     move.l    pr_ConsoleTask(a0),packettask(a5)
  1719.     moveq    #ACTION_READ,d0
  1720.     move.l    d0,packettype(A5)
  1721.     bsr    sendpacket2    read keyboard with packets
  1722.     moveq    #0,d3
  1723.     move.l    thistask(a5),a0
  1724.     move.b    pr_MsgPort+MP_SIGBIT(a0),d1
  1725.     bset    d1,d3        set wait bit for reading
  1726.     move.l    appwinport(a5),d2
  1727.     beq.s    .A
  1728.     move.l    d2,a0
  1729.     move.b    MP_SIGBIT(a0),d1
  1730.     bset    d1,d3        set wait bit for appwindow
  1731. .A    move.l    d3,d0
  1732.     jsr    _LVOWait(a6)    wait for anything
  1733.     tst.l    d2
  1734.     beq.s    .B
  1735.     move.l    d2,a0
  1736.     jsr    _LVOGetMsg(a6)    try to get appwinmsg
  1737.     tst.l    d0
  1738.     beq.s    .B
  1739.     move.l    d0,a2
  1740.     bsr    ProcessApp    look at it
  1741.     move.l    a2,a1
  1742.     jsr    _LVOReplyMsg(a6)
  1743.     move.l    dosbase(a5),a6
  1744.     lea    tempbuf(a5),a1
  1745.     move.l    d2,-(sp)
  1746.     bsr    insert_string    write iconname to shelline
  1747.     move.l    d5,old_linhere(a5)
  1748.     move.l    d4,old_linmax(a5)
  1749.     move.l    (sp)+,d2
  1750.     move.l    intuibase(a5),a6
  1751.     move.l    windowptr(a5),d0
  1752.     beq.s    .C
  1753.     move.l    d0,a0
  1754.     jsr    _LVOActivateWindow(a6)
  1755. .C    move.l    4.w,a6
  1756.  
  1757. .B    move.l    thistask(a5),a0
  1758.     lea    pr_MsgPort(a0),a0
  1759.     jsr    _LVOGetMsg(a6)    try to get read-packet-reply
  1760.     move.l    d0,d1
  1761.     beq.s    .A
  1762.     move.l    dosbase(a5),a6
  1763.     lea    sp_node(a5),a0
  1764.     move.l    #212,d0
  1765.     cmp.l    d1,a0
  1766.     bne    pr_galactic    got wrong dospacket
  1767.     tst.l    sp_res1(a5)
  1768.     bmi.s    .D        error occured
  1769.     beq.s    .E
  1770.     move.b    tempbytes(a5),d6
  1771.     rts
  1772. .D    moveq    #20,d1
  1773.     bra.s    .F
  1774. .E    moveq    #21,d1
  1775. .F    bsr    GuruIt
  1776.     bra    ExitZShell
  1777.  
  1778. saveundo
  1779.     lea    shelline(a5),a0
  1780.     lea    CLIbuf(a5),a1
  1781.     move.l    d4,d0
  1782.     bra.s    .B
  1783. .A    move.b    (a0)+,(a1)+
  1784. .B    dbra    d0,.A
  1785.     clr.b    (a1)
  1786.     rts
  1787.  
  1788. * A1 pts to past, d0=nost
  1789. gimme    lea    shelline(a5),a2    Get shelline from history
  1790.     move.l    d0,nost(a5)
  1791.     cmp.l    now(a5),d0
  1792.     bne.s    .C
  1793.     moveq    #-1,d4        reset linmax
  1794.     lea    CLIbuf(a5),a0
  1795. .D    addq.l    #1,d4
  1796.     move.b    (a0)+,(a2)+    copy undo to shelline
  1797.     bne.s    .D
  1798.     move.l    d4,d5        linmax=linhere
  1799.     bra    gimme3
  1800.  
  1801. .C    moveq    #0,d5        linhere = 0
  1802. .B    addq.l    #1,d0        copy to shelline
  1803.     and.l    #HISTORY_SIZE-1,d0
  1804.     cmp.b    #LF,0(a1,d0.l)
  1805.     beq.s    .A
  1806.     move.b    0(a1,d0.l),0(a2,d5.l)
  1807.     addq.l    #1,d5
  1808.     bra.s    .B
  1809. .A    move.l    d5,d4        linhere=linmax
  1810.  
  1811. gimme3    bsr    pr_hide_cursor        Print out newer shelline
  1812.     move.l    old_linhere(a5),d0    and overwrite old one
  1813.     bsr    cursor_left    go to left start of line
  1814.     lea    shelline(a5),a1
  1815.     move.l    a1,a0
  1816.     add.l    d4,a0
  1817.     move.l    d4,d0
  1818.     move.l    old_linmax(a5),d1
  1819.     sub.l    d4,d1
  1820.     bmi.s    .A
  1821.     add.l    d1,d0
  1822.     bra.s    .C
  1823. .D    move.b    #" ",(a0)+    append some spaces, if needed
  1824. .C    dbra    d1,.D
  1825. .A    clr.b    (a0)
  1826.     bsr    pr_string    overwrite old line
  1827.     sub.l    d5,d0
  1828.     bsr    cursor_left    restore cursor
  1829.     bra    pr_show_cursor
  1830.  
  1831. gimme4    bsr    pr_prompt        Print out shelline again
  1832. gimme2    lea    shelline(a5),a1
  1833.     clr.b    0(a1,d4.l)    clear last byte
  1834.     bsr    pr_string    print shelline
  1835.     bsr    pr_show_cursor
  1836. restore_cursor
  1837.     move.l    d4,d0
  1838.     sub.l    d5,d0
  1839.  
  1840. cursor_left    ;move cursor d0 chars left
  1841.     move.l    d0,-(sp)
  1842.     beq.s    .A
  1843.     bsr    csi_with_num
  1844.     move.b    #"D",(a0)
  1845.     bsr    pr_string
  1846. .A    move.l    (sp)+,d0
  1847.     rts
  1848.  
  1849. cursor_right    ;move cursor d0 chars right
  1850.     move.l    d0,-(sp)
  1851.     beq.s    .A
  1852.     bsr    csi_with_num
  1853.     move.b    #"C",(a0)
  1854.     bsr    pr_string
  1855. .A    move.l    (sp)+,d0
  1856.     rts
  1857.  
  1858. csi_with_num    ;puts $9b and number in d0 to tempbuf=a1
  1859.     lea    NewPrintBuffer(a5),a1
  1860.     move.l    a1,a0
  1861.     move.b    #$9b,(a0)+
  1862.     bsr    dec2asc
  1863.     clr.b    1(a0)
  1864.     rts
  1865.  
  1866. ************************************************************************
  1867. * READ TEXT LINE from keyboard or script into buffer pointed to by a0,
  1868. * and clear last byte. NOTE A0 is essentially ignored, and shelline is the
  1869. * assumed address. Return with a0 same, and d0=length of text read
  1870. type_in    tst.b    scflag(a5)        ;check whether we're doing a script
  1871.     bne    scr_in
  1872.     move.l    a0,-(sp)
  1873.     moveq    #0,d5        D5=linhere
  1874.     moveq    #0,d4        D4=linmax
  1875.     btst    #FLraw,Flags+2(a5)    test noraw-mode
  1876.     bne.s    .A
  1877.     move.l    a0,a2            use console in cooked mode
  1878. .C    move.l    a2,d2
  1879.     move.l    stdin(a5),d1
  1880.     beq    ExitZShell
  1881.     move.l    #SHELLINE_SIZE,d3
  1882.     jsr    _LVORead(a6)
  1883.     tst.l    d0
  1884.     bmi    ExitZShell
  1885.     bne.s    .D
  1886.     bsr    Kiconify
  1887.     bclr    #FLraw,Flags+2(a5)
  1888.     bra.s    .C
  1889. .D    clr.b    0(a2,d0.l)
  1890.     cmp.b    #LF,-1(a2,d0.l)
  1891.     bne.s    .C
  1892.     bsr    GetWindowPtr
  1893.     move.l    (sp)+,a0
  1894.     rts
  1895.     
  1896. .A    clr.b    CLIbuf(a5)    (for undo)    use console in raw mode
  1897.     addq.b    #1,noreview_flag(a5)
  1898. next_ch    move.l    d5,old_linhere(a5)
  1899.     move.l    d4,old_linmax(a5)
  1900.     bsr    raw_on        MAKE SURE RAW MODE IS ON
  1901.     bsr    get_one_char
  1902.     cmp.b    #$9b,d6
  1903.     bne    not_csi
  1904.     clr.l    gather_ptr(a5)
  1905. fetch_csi    bsr    get_one_char
  1906.     lea    gather(a5),a2
  1907.     move.l    gather_ptr(a5),d0
  1908.     move.b    d6,0(a2,d0.l)        save byte from CSI sequence.
  1909.     addq.l    #1,gather_ptr(a5)
  1910.     moveq    #79,d1
  1911.     cmp.l    d1,d0
  1912.     blo.s    .A
  1913.     clr.l    gather_ptr(a5)
  1914. .A    cmp.b    #'@',d6
  1915.     blo.s    fetch_csi        keep gathering if char < @
  1916.     cmp.b    #'~',d6
  1917.     bhi.s    fetch_csi        keep gathering if char > ~
  1918.  
  1919. Krawevent
  1920.     cmp.b    #"|",d6        CHECK RAW EVENTS
  1921.     bne    Kfunc_key
  1922.     move.l    a2,a1
  1923.     bsr    convert_ASCII_to_num
  1924. ev_menu    moveq    #10,d1
  1925.     cmp.l    d0,d1        CHECK MENU EVENT
  1926.     bne.s    ev_clog
  1927.     bsr    convert_ASCII_to_num
  1928.     bsr    convert_ASCII_to_num
  1929.     move.l    windowptr(a5),d1
  1930.     beq.s    .C
  1931.     move.l    d1,a0
  1932.     move.l    28(a0),a0    Window->MenuStrip
  1933.     move.l    intuibase(a5),a6
  1934.     jsr    _LVOItemAddress(a6)
  1935.     move.l    dosbase(a5),a6
  1936.     tst.l    d0
  1937.     beq.s    .C
  1938.     move.l    d0,a0
  1939.     move.l    mi_SIZEOF(a0),d0
  1940. .C    beq    next_ch
  1941.     move.l    d0,a1
  1942.     bra    insert_macro
  1943.  
  1944. ev_clog    moveq    #11,d1
  1945.     cmp.l    d0,d1        CHECK CLOSE GADGET EVENT
  1946.     bne.s    .A
  1947.     bsr    Kiconify
  1948. .A    bra    next_ch
  1949.  
  1950. ExitZShell
  1951.     move.l    dosbase(a5),a6        TOTALLY-EXIT-ROUTINE
  1952.     move.l    errorstack(a5),sp    kill return address on stack
  1953.     bsr    close_redirection
  1954.     bsr    raw_off
  1955.     bsr    kill_script
  1956.     moveq    #-1,d7
  1957.     rts
  1958.  
  1959. Kfunc_key
  1960.     cmp.b    #'~',d6        CHECK FUNCTION KEYS AND HELP KEY
  1961.     bne    Kcsr_right
  1962. * TRANSLATE FUNC CODE TO F1,F2 ETC AND SET UP POINTERS
  1963.     lea    temp2buf(a5),a1    create search string in temp2buf
  1964.     cmp.b    #"?",(a2)    a2=gather
  1965.     bne.s    .E
  1966.     lea    help_ret(pc),a1    HELP KEY
  1967.     bra.s    insert_macro
  1968.  
  1969. .E    move.l    gather_ptr(a5),d0
  1970.     cmp.b    #3,d0        check if two codes eg '12'
  1971.     bne.s    .A
  1972.     move.b    #"S",(a1)+    SHIFT+FUNCTION
  1973.     addq.l    #1,a2
  1974.     bra.s    .C
  1975. .A    cmp.b    #2,d0        UNSHIFTED FUNCTION
  1976.     bne.s    next_c8
  1977.  
  1978. .C    move.b    (a2),d0
  1979.     move.b    #"F",(a1)+    insert "F"
  1980.     addq.b    #1,d0
  1981.     move.b    d0,(a1)+    insert one digit number
  1982.     cmp.b    #':',d0
  1983.     blo.s    .D
  1984.     move.b    #'1',-1(a1)    insert 10
  1985.     move.b    #'0',(a1)+
  1986. .D    clr.b    (a1)
  1987.  
  1988.     bsr    search_alias    returns d0=pointer to alias
  1989.     beq.s    next_c8
  1990.     move.l    d0,a1
  1991.     lea    4(a1),a1    skip link and name
  1992. .F    tst.b    (a1)+
  1993.     bne.s    .F
  1994. insert_macro        ;Insert macro definition in a1 into shelline
  1995.     lea    dest_label(a5),a0    good enough for temporary
  1996.     move.l    a0,getmemchar(a5)    let it read in by Getonechar
  1997.     move.l    a0,d0
  1998.     moveq    #58,d1
  1999. .A    move.b    (a1)+,(a0)+
  2000.     beq.s    .C
  2001.     dbra    d1,.A
  2002. .C    clr.b    (a0)
  2003.     bsr    parse_echo    convert control characters
  2004. next_c8    bra    next_ch
  2005.  
  2006.  
  2007. Kcsr_right
  2008.     cmp.b    #' ',gather(a5)    check for shifted cursor up/down
  2009.     beq    Kshift_left
  2010.     cmp.b    #'C',d6        CHECK RIGHT ARROW    <CSI>C
  2011.     bne.s    Kcsr_left
  2012.     move.l    FNCcycle(a5),d0
  2013.     beq.s    .B
  2014.     cmp.l    FNCbuffer(a5),d0
  2015.     bne.s    .A
  2016. .B    cmp.l    d4,d5
  2017.     bhs.s    Kcsr_left
  2018.     addq.l    #1,d5
  2019.     moveq    #1,d0
  2020.     bsr    cursor_right
  2021. .A    clr.l    FNCcycle(a5)
  2022.     bra.s    next_c8
  2023.  
  2024. Kcsr_left
  2025.     clr.l    FNCcycle(a5)
  2026.     cmp.b    #'D',d6        CHECK LEFT ARROW    <CSI>D
  2027.     bne.s    Kcsr_up
  2028.     tst.l    d5
  2029.     beq.s    Kcsr_up
  2030.     subq.l    #1,d5
  2031.     moveq    #1,d0
  2032.     bsr    cursor_left
  2033.     bra.s    next_c8
  2034.  
  2035. Kcsr_up    cmp.b    #'A',d6        CHECK UP ARROW        <CSI>A
  2036.     bne.s    Kcsr_down
  2037.     lea    past(a5),a1
  2038.     move.l    nost(a5),d0
  2039.     cmp.l    then(a5),d0
  2040.     beq.s    .B
  2041. .A    subq.l    #1,d0
  2042.     and.l    #HISTORY_SIZE-1,d0    wrap around
  2043.     cmp.b    #LF,0(a1,d0.l)
  2044.     bne.s    .A
  2045. .B    bsr    gimme
  2046. next_c5    bra.s    next_c8
  2047.  
  2048. Kcsr_down
  2049.     cmp.b    #'B',d6        CHECK DOWN ARROW    <CSI>B
  2050.     bne.s    Kshift_tab
  2051. up_bit    lea    past(a5),a1    called by shift down bit
  2052.     move.l    nost(a5),d0
  2053.     cmp.l    now(a5),d0
  2054.     beq.s    .B
  2055. .A    addq.l    #1,d0
  2056.     and.l    #HISTORY_SIZE-1,d0
  2057.     cmp.b    #LF,0(a1,d0.l)
  2058.     bne.s    .A
  2059. .B    bsr    gimme
  2060.     bra.s    next_c5
  2061.  
  2062. Kshift_tab
  2063.     cmp.b    #'Z',d6        CHECK TAB & SHIFT    <CSI>Z
  2064.     bne.s    Kshift_down
  2065.     move.b    #"Y"&$3f,d6    emulate CTRL-Y
  2066.     bra    not_csi
  2067.  
  2068. Kshift_down
  2069.     cmp.b    #'S',d6        CHECK SHIFT DOWN    <CSI>S
  2070.     bne.s    Kshift_up
  2071.     move.l    now(a5),nost(a5)    nost = now (the bottom)
  2072.     bra.s    up_bit
  2073.  
  2074. Kshift_up
  2075.     cmp.b    #'T',d6        CHECK SHIFT UP        <CSI>T
  2076.     bne.s    next_c5
  2077.     lea    past(a5),a1
  2078.     tst.l    d5
  2079.     bne.s    search_his
  2080.     move.l    then(a5),nost(a5)    nost = then (the top)
  2081.     move.l    nost(a5),d0
  2082.     bsr    gimme
  2083. next_c6    bra.s    next_c5
  2084. search_his            ;search shelline in history    V2.0
  2085.     move.l    nost(a5),d0
  2086. .C    cmp.l    then(a5),d0
  2087.     bne.s    .A
  2088.     move.l    nost(a5),d0
  2089.     bra.s    end_seh
  2090. .A    subq.l    #1,d0
  2091.     and.l    #HISTORY_SIZE-1,d0
  2092.     cmp.b    #LF,0(a1,d0.l)
  2093.     bne.s    .A
  2094.  
  2095.     lea    shelline(a5),a0
  2096.     move.l    d5,d1
  2097.     subq.l    #1,d1
  2098.     move.l    d0,d2
  2099. .D    addq.l    #1,d2
  2100.     and.l    #HISTORY_SIZE-1,d2
  2101.     movem.l    d0/d1,-(sp)
  2102.     move.b    0(a1,d2.l),d0
  2103.     move.b    (a0),d1
  2104.     bsr    compD1D0locale
  2105.     movem.l    (sp)+,d0/d1
  2106.     bne.s    .C
  2107.     addq.l    #1,a0
  2108.     dbra    d1,.D
  2109. end_seh    move.l    d5,d2        save d5
  2110.     bsr    gimme
  2111.     move.l    d2,d5
  2112.     bsr    restore_cursor
  2113.     bra.s    next_c6
  2114.  
  2115.  
  2116. Kshift_left
  2117.     clr.l    FNCcycle(a5)
  2118.     cmp.b    #'A',d6        CHECK SHIFT LEFT ARROW    <CSI> A
  2119.     bne.s    Kshift_right
  2120.     move.l    d5,d0
  2121.     bsr    cursor_left
  2122.     moveq    #0,d5
  2123. next_c7    bra.s    next_c6
  2124.  
  2125. Kshift_right
  2126.     cmp.b    #'@',d6        CHECK SHIFT RIGHT ARROW    <CSI> @
  2127.     bne.s    next_c7
  2128.     move.l    d4,d0
  2129.     sub.l    d5,d0
  2130.     bsr    cursor_right
  2131.     move.l    d4,d5
  2132.     bra.s    next_c7
  2133.  
  2134. *********************************************************************
  2135. * Was not a CSI code
  2136. not_csi    tst.l    FNCcycle(a5)            CHECK BACKTICK
  2137.     beq.s    .C    only in fnc-cycle mode
  2138.     cmp.b    #"`",d6
  2139.     bne.s    .C
  2140.     addq.b    #1,FNCback(a5)
  2141.     bra.s    .D
  2142.  
  2143. .C    cmp.b    ctrl_codes+4(a5),d6        CHECK TAB
  2144.     bne.s    not_fnc
  2145. .D    bsr    RequestersOff
  2146.     move.l    FNCcycle(a5),-(sp)
  2147.     bsr    complet        complete filename
  2148.     tst.l    (sp)+
  2149.     bne.s    .A
  2150.     bsr    saveundo
  2151. .A    bsr    RequestersOn
  2152.     clr.b    FNCback(a5)
  2153.     bra.s    next_c7
  2154.  
  2155. not_fnc
  2156.     clr.l    FNCcycle(a5)
  2157.     lea    ctrl_codes(a5),a0
  2158.     lea    ctrlkeys_tab(pc),a1
  2159.     moveq    #ctrl_inite-ctrl_init-2,d0
  2160. .A    cmp.b    (a0)+,d6
  2161.     bne.s    .C
  2162.     move.w    (a1),d0
  2163.     lea    not_csi(pc),a0
  2164.     jsr    0(a0,d0.w)
  2165.     bra.s    next_c7
  2166. .C    addq.l    #2,a1
  2167.     dbra    d0,.A
  2168.  
  2169. not_ctrlkey
  2170.     cmp.b    #$7f,d6                CHECK DELETE
  2171.     bne.s    not_del
  2172.     cmp.l    d4,d5
  2173.     bhs.s    .A
  2174.     moveq    #1,d0
  2175.     bsr    delete_chars
  2176. .A
  2177. next_c9    bra.s    next_c7
  2178.  
  2179. not_del
  2180.     cmp.b    #13,d6                CHECK CR
  2181.     beq    do_cr
  2182.     cmp.b    #" ",d6                CHECK normal char
  2183.     blo.s    .C
  2184.     cmp.w    #SHELLINE_SIZE-2,d4    INSERT A CHAR IN THE SHELLINE
  2185.     blo.s    .D
  2186.     bsr    DisplayBeep        make sure line is not too long
  2187.     bra.s    .C
  2188. .D    bsr    pr_hide_cursor
  2189.     lea    shelline(a5),a1    ethel
  2190.     lea    1(a1,d4.w),a0    linmax
  2191.     lea    1(a0),a2    A2=linmax+1
  2192.     lea    0(a1,d5.w),a1    linhere
  2193. .A    move.b    -(a0),-(a2)    insert char into shelline
  2194.     cmp.l    a0,a1
  2195.     bne.s    .A
  2196.     lea    shelline(a5),a1
  2197.     move.b    d6,0(a1,d5.w)
  2198.     addq.l    #1,d4
  2199.     clr.b    0(a1,d4.l)    clear last
  2200.     add.l    d5,a1
  2201.     bsr    pr_string    print last part of line
  2202.     addq.l    #1,d5
  2203.     move.l    d4,d0
  2204.     sub.l    d5,d0
  2205.     bsr    cursor_left    restore cursor
  2206.     bsr    pr_show_cursor
  2207.     bsr    saveundo
  2208. .C    bra.s    next_c9
  2209.  
  2210.  
  2211. ctrlkeys_tab
  2212.     dc.w    Kdel_right_word-not_csi        0  CTRL-W
  2213.     dc.w    Kdel_left_word-not_csi        1  CTRL-Q
  2214.     dc.w    Kdel_to_start-not_csi        2  CTRL-S
  2215.     dc.w    Kdel_to_end-not_csi        3  CTRL-E
  2216.     dc.w    DisplayBeep-not_csi        4  CTRL-I (TAB)
  2217.     dc.w    Kdel_line-not_csi        5  CTRL-X
  2218.     dc.w    Kiconify-not_csi        6  CTRL-[ (ESC)
  2219.     dc.w    Kword_right-not_csi        7  CTRL-T
  2220.     dc.w    Kshow_review-not_csi        8  CTRL-Y (Shift-TAB)
  2221.     dc.w    Kbackspace-not_csi        9  CTRL-H (Backspace)
  2222.     dc.w    Kto_history-not_csi        10 CTRL-J (Shift-Return)
  2223.     dc.w    Kreturn-not_csi            11 CTRL-M (Return)
  2224.     dc.w    Kclear_screen-not_csi        12 CTRL-L
  2225.     dc.w    Kword_left-not_csi        13 CTRL-R
  2226.     dc.w    Kshow_history-not_csi        14 CTRL-V
  2227.     dc.w    Krequest_file-not_csi        15 CTRL-F
  2228.     dc.w    FlushFNC-not_csi        16 CTRL-P
  2229.  
  2230.  
  2231. back_chars        ;delete d0 chars left to cursor
  2232.     sub.l    d0,d5
  2233.     bmi    GuruIt
  2234.     bsr    cursor_left
  2235. delete_chars        ;delete d0 chars under cursor
  2236.     bsr    delete_in_mem
  2237.     move.l    d0,d1
  2238.     bra.s    .D
  2239. .E    move.b    #" ",(a0)+    append spaces to overwrite
  2240. .D    dbra    d1,.E
  2241.     clr.b    (a0)
  2242.     bsr    pr_hide_cursor
  2243.     lea    shelline(a5),a1
  2244.     add.l    d5,a1
  2245.     bsr    pr_string    print last part of line
  2246.     add.l    d4,d0
  2247.     sub.l    d5,d0
  2248.     bsr    cursor_left    restore cursor
  2249.     bsr    pr_show_cursor
  2250.     rts
  2251.  
  2252. delete_in_mem        ;delete d0 chars under cursor in shelline(a5)
  2253.     lea    shelline(a5),a0
  2254.     add.l    d5,a0
  2255.     lea    0(a0,d0.l),a1
  2256.     move.l    d4,d1
  2257.     sub.l    d5,d1
  2258.     sub.l    d0,d1
  2259.     bmi    GuruIt
  2260.     bra.s    .B
  2261. .A    move.b    (a1)+,(a0)+    copy last part of line
  2262. .B    dbra    d1,.A
  2263.     sub.l    d0,d4
  2264.     rts
  2265.  
  2266. word_left
  2267.     lea    shelline-1(a5),a0
  2268.     add.l    d5,a0
  2269.     moveq    #0,d0
  2270.     move.l    d5,d1
  2271. .F    beq.s    .D
  2272.     bsr    tab_check
  2273.     bne.s    .C
  2274.     addq.l    #1,d0
  2275.     subq.l    #1,a0
  2276.     subq.l    #1,d1
  2277.     bra.s    .F
  2278. .A    bsr    tab_check
  2279.     beq.s    .D
  2280.     addq.l    #1,d0
  2281.     subq.l    #1,a0
  2282. .C    dbra    d1,.A
  2283. .D    rts
  2284.  
  2285. word_right
  2286.     lea    shelline(a5),a0
  2287.     add.l    d5,a0
  2288.     moveq    #0,d0
  2289.     move.l    d4,d1
  2290.     sub.l    d5,d1
  2291. .F    beq.s    .D
  2292.     bsr    tab_check
  2293.     beq.s    .C
  2294.     addq.l    #1,d0
  2295.     addq.l    #1,a0
  2296.     subq.l    #1,d1
  2297.     bra.s    .F
  2298. .A    bsr    tab_check
  2299.     bne.s    .D
  2300.     addq.l    #1,d0
  2301.     addq.l    #1,a0
  2302. .C    dbra    d1,.A
  2303. .D    rts
  2304.  
  2305. tab_check cmp.b    #' ',(a0) words are separated by / . : ; | or space
  2306.     beq.s    .A
  2307.     cmp.b    #':',(a0)
  2308.     beq.s    .A
  2309.     cmp.b    #'.',(a0)
  2310.     beq.s    .A
  2311.     cmp.b    #'/',(a0)
  2312.     beq.s    .A
  2313.     cmp.b    #';',(a0)
  2314.     beq.s    .A
  2315.     cmp.b    #'|',(a0)
  2316. .A    rts
  2317.  
  2318. Kword_left
  2319.     bsr    word_left    go to last word
  2320.     sub.l    d0,d5
  2321.     bra    cursor_left
  2322.  
  2323. Kword_right
  2324.     bsr    word_right    go to next word
  2325.     add.l    d0,d5
  2326.     bra    cursor_right
  2327.  
  2328. Kbackspace
  2329.     tst.l    d5
  2330.     beq.s    .A
  2331.     moveq    #1,d0
  2332.     bsr    back_chars    delete one char left to cursor
  2333. .A    rts
  2334.  
  2335. Kdel_to_start
  2336.     move.l    d5,d0
  2337.     bra    back_chars    delete to start of line
  2338.  
  2339. Kdel_to_end
  2340.     move.l    d4,d0
  2341.     sub.l    d5,d0
  2342.     bra    delete_chars    delete to end of line
  2343.  
  2344. Kdel_left_word
  2345.     bsr    word_left    delete last word
  2346.     bsr    back_chars
  2347.     rts
  2348.  
  2349. Kdel_right_word
  2350.     bsr    word_right    delete next word
  2351.     bra    delete_chars
  2352.  
  2353. Kdel_line
  2354.     bsr    saveundo
  2355.     moveq    #0,d4
  2356.     moveq    #0,d5
  2357.     bra    gimme3        delete whole shelline
  2358.  
  2359. Kto_history
  2360.     bsr    do_cr2        push line to history
  2361.     move.l    errorstack(a5),sp
  2362.     bra    chorus
  2363.  
  2364. Kclear_screen
  2365.     lea    clrtx(pc),a1
  2366.     bsr    pr_string    clear window
  2367.     bra    gimme4
  2368.  
  2369. Kshow_history
  2370.     movem.l    d3-d7/a2-a4,-(sp)
  2371.     lea    past(a5),a2
  2372.     move.l    now(a5),d3
  2373.     move.l    #HISTORY_SIZE,d2
  2374.     sub.l    a3,a3
  2375.     bsr    viewhist    view history buffer with MORE
  2376.     movem.l    (sp)+,d3-d7/a2-a4
  2377.     bra    gimme4
  2378.  
  2379. Kshow_review
  2380.     tst.l    ReviewSize(a5)
  2381.     beq.s    .A
  2382.     movem.l    d3-d7/a2-a4,-(sp)
  2383.     sub.l    a3,a3
  2384.     bsr    viewbuffer    view review buffer with MORE
  2385.     movem.l    (sp)+,d3-d7/a2-a4
  2386.     bsr    gimme4
  2387. .A    rts
  2388.  
  2389. Kiconify
  2390.     btst    #FLappicon,Flags+3(a5)
  2391.     beq    ExitZShell    exit immediately
  2392.     tst.b    openwin_flag(a5)
  2393.     beq    ExitZShell
  2394.     bsr    WaitAppIcon
  2395.     bsr    gimme4
  2396.     lea    tempbuf(a5),a1
  2397.     tst.b    (a1)
  2398.     beq.s    .A
  2399.     bsr    insert_string
  2400. .A    rts
  2401.  
  2402. Krequest_file
  2403.     move.l    4.w,a6        Display Filerequester
  2404.     lea    aslname(pc),a1
  2405.     jsr    _LVOOldOpenLibrary(a6)
  2406.     move.l    d0,d7
  2407.     beq    .A
  2408.     move.l    dosbase(a5),a6
  2409.     bsr    name2complete
  2410.     move.l    d7,a6
  2411.     lea    tempbuf(a5),a0
  2412.     move.l    a0,a3
  2413.     move.l    d6,d7
  2414. .F    addq.l    #1,d7
  2415.     move.b    (a1)+,(a0)+        copy path
  2416.     bne.s    .F
  2417.     move.b    d3,(a2)            replace null-char by old one
  2418.     move.l    a0,a1
  2419.     bra.s    .G
  2420. .H    move.b    (a2)+,(a0)+        copy pattern or filepart
  2421. .G    dbra    d6,.H
  2422.     tst.b    wild_flag(a5)
  2423.     bne.s    .I
  2424.     move.b    #"*",(a0)+
  2425. .I    clr.b    (a0)
  2426.     lea    temp2buf(a5),a0
  2427.     moveq    #-1,d0
  2428.     move.l    a0,a2
  2429.     move.l    #ASL_TB+10,(a2)+    InitialPattern
  2430.     move.l    a1,(a2)+
  2431.     move.l    #ASL_TB+9,(a2)+        InitialDrawer
  2432.     move.l    a3,(a2)+
  2433.     move.l    #ASL_TB+43,(a2)+    SleepWindow
  2434.     move.l    d0,(a2)+
  2435.     move.l    #ASL_TB+1,(a2)+        TitleText
  2436.     lea    ZShellName(pc),a1
  2437.     move.l    a1,(a2)+
  2438.     move.l    #ASL_TB+46,(a2)+    DoPatterns
  2439.     move.l    d0,(a2)+
  2440.     btst    #FLwild,Flags+3(a5)
  2441.     beq.s    .E
  2442.     move.l    #ASL_TB+61,(a2)+    RejectPattern
  2443.     lea    FNCignore(a5),a1
  2444.     move.l    a1,(a2)+
  2445. .E    move.l    #ASL_TB+63,(a2)+    FilterDrawers
  2446.     clr.l    (a2)+
  2447.     clr.l    (a2)
  2448.     moveq    #0,d0
  2449.     jsr    _LVOAllocAslRequest(a6)
  2450.     move.l    d0,d3
  2451.     beq.s    .B
  2452.     move.l    d3,a0        request-struct
  2453.     move.l    a2,a1        no tags
  2454.     jsr    _LVOAslRequest(a6)
  2455.     tst.l    d0
  2456.     beq.s    .C
  2457.     move.l    d3,a0
  2458.     move.l    rf_File(a0),a1
  2459.     move.l    rf_Dir(a0),a0
  2460.     lea    tempbuf(a5),a2
  2461.     move.l    a2,a3
  2462.     bsr    addpath
  2463. .D    tst.b    (a2)+
  2464.     bne.s    .D
  2465.     subq.l    #1,a2
  2466.     bsr    MaybeInsertQuote
  2467.     move.b    #" ",(a2)+
  2468.     clr.b    (a2)
  2469.     move.l    a3,a1
  2470.     move.l    d7,d2
  2471.     subq.l    #1,d2
  2472.     move.l    a6,a4
  2473.     move.l    dosbase(a5),a6
  2474.     bsr    insert_string2
  2475.     move.l    a4,a6
  2476. .C    move.l    d3,a0
  2477.     jsr    _LVOFreeAslRequest(a6)
  2478. .B    move.l    a6,a1
  2479.     move.l    4.w,a6
  2480.     jsr    _LVOCloseLibrary(a6)
  2481. .A    move.l    dosbase(a5),a6
  2482.     rts
  2483.  
  2484. ******************************************************************
  2485. Kreturn    addq.l    #4,sp
  2486. do_cr    move.l    (sp)+,a2
  2487. do_cr2    move.l    d4,d0
  2488.     sub.l    d5,d0
  2489.     bsr    cursor_right    to end of line
  2490.     bsr    pr_lf
  2491.     lea    shelline(a5),a4
  2492.     move.b    #LF,0(a4,d4.w)    hack job    (MUST END IN LF 0)
  2493.     clr.b    1(a4,d4.w)    for alias stuff
  2494.     tst.l    d4        nothing typed ?
  2495.     beq    finland
  2496. ;push it to history
  2497.     lea    past(a5),a1    CHECK IF LAST ENTRY IS SAME AS CURRENT
  2498.     move.l    now(a5),d0
  2499.     cmp.l    then(a5),d0
  2500.     beq.s    .B
  2501.     move.l    d0,nost(a5)
  2502. .A    subq.l    #1,d0        FIND LAST
  2503.     and.l    #HISTORY_SIZE-1,d0    WRAP AROUND
  2504.     cmp.b    #LF,0(a1,d0.l)
  2505.     bne.s    .A
  2506.     lea    (a4),a0
  2507.     bra.s    .C
  2508. .D    cmp.b    #LF,d1        COMPARE LAST TO SHELLINE
  2509.     beq    finland
  2510. .C    addq.l    #1,d0
  2511.     and.l    #HISTORY_SIZE-1,d0
  2512.     move.b    (a0)+,d1
  2513.     cmp.b    0(a1,d0.l),d1
  2514.     beq.s    .D
  2515.  
  2516. .B    move.l    a4,a3    lin    COPY LINE TO HISTORY  BUFFER
  2517.     move.l    now(a5),d3    pts to the last LF
  2518.  
  2519. .E    addq.l    #1,d3
  2520.     and.l    #HISTORY_SIZE-1,d3        WRAP AROUND
  2521.     move.b    (a3)+,d0
  2522.     move.b    d0,0(a1,d3.l)
  2523.     cmp.b    #LF,d0
  2524.     bne.s    .E
  2525. ;dumped_hist
  2526.     move.l    d3,nost(a5)    nost = now
  2527.     move.l    d3,now(a5)
  2528.     move.l    then(a5),d1
  2529.     cmp.b    #LF,0(a1,d1.l)
  2530.     bne.s    .G    BRANCH IF WRAPPED AROUND
  2531.     cmp.l    d3,d1
  2532.     bne.s    finland    BRANCH IF THEN = (10) & THEN <> NOW
  2533. .G    
  2534. *    move.l    d3,then(a5)    then=now
  2535. .H    addq.l    #1,d3    SEARCH FOR NEXT LF (NEW TOP OF HISTORY)
  2536.     and.l    #HISTORY_SIZE-1,d3        WRAP AROUND
  2537.     move.b    0(a1,d3.l),d0
  2538.     cmp.b    #LF,d0
  2539.     bne.s    .H        ***
  2540.     move.l    d3,then(a5) SET NEW THEN (TOP OF HISTORY)
  2541.  
  2542. ******* 
  2543. finland    lea    prompt_string(a5),a1    write to review-buffer
  2544.     move.l    a1,d2
  2545.     moveq    #-1,d3
  2546. .E    addq.l    #1,d3
  2547.     tst.b    (a1)+
  2548.     bne.s    .E
  2549.     bsr    toreview
  2550.     move.l    a2,d2
  2551.     move.l    d4,d3
  2552.     addq.l    #1,d3
  2553.     bsr    toreview
  2554. .D    bsr    GetWindowPtr
  2555.     bsr    raw_off
  2556.     move.l    a2,a0
  2557.     move.l    d4,d0
  2558.     rts
  2559.  
  2560. ;    End of Command Line Editor
  2561. **********************************************
  2562.  
  2563.  
  2564. * DO SCRIPT FILE STUFF   ENTRY A0 -> input line
  2565. scr_in    movem.l    a0-a1/a6,-(sp)
  2566.     clr.b    break_flag(a5)
  2567.     move.l    4.w,a6
  2568.     moveq    #0,d0
  2569.     moveq    #0,d1
  2570.     bset    #SIGBREAKB_CTRL_D,d1
  2571.     jsr    _LVOSetSignal(a6)
  2572.     movem.l    (sp)+,a0-a1/a6
  2573.     btst    #SIGBREAKB_CTRL_D,d0    ;checks if CTRL_D pressed
  2574.     beq.s    .B
  2575.     move.l    #304,d0
  2576.     bsr    pr_DOSerr
  2577.     move.b    #1,break_flag(a5)
  2578.     bra.s    terminate_script
  2579. .B    move.l    scsize(a5),d1    ;read a line from the script file
  2580.     add.l    scaddr(a5),d1
  2581.     sub.l    scptr(a5),d1
  2582.     beq.s    terminate_script
  2583.     bpl.s    scr_in2
  2584. terminate_script
  2585.     bsr    kill_script
  2586.     move.l    errorstack(a5),sp
  2587.     bra    chorus
  2588.  
  2589. scr_in2    move.l    a0,a2
  2590.     move.l    #SHELLINE_SIZE-2,d2
  2591.     moveq    #0,d0
  2592.     move.l    scptr(a5),a1
  2593.     cmp.b    #LF,(a1)    single LF line ?
  2594.     beq.s    .B
  2595. .A    move.b    (a1)+,(a2)+    copy line from script
  2596. .F    subq.l    #1,d2        check shelline size limit
  2597.     beq.s    .G
  2598.     addq.l    #1,d0
  2599.     subq.l    #1,d1
  2600.     bne.s    .D
  2601. .G    move.b    #LF,(a2)+    script end without LF
  2602.     bra.s    .E
  2603. .D    cmp.b    #LF,(a1)    LF at end of line ?
  2604.     bne.s    .A
  2605.     cmp.b    #$5c,-1(a1)    escaped ?
  2606.     bne.s    .B
  2607.     subq.l    #1,a2        YES: skip LF and overwrite \
  2608.     addq.l    #1,a1
  2609.     bra.s    .F
  2610. .B    move.b    (a1)+,(a2)+    LF
  2611. .E    clr.b    (a2)        0 at end
  2612.     move.l    a1,scptr(a5)
  2613.     btst    #FLdebug,Flags+3(a5)    debug output ?
  2614.     beq.s    .C
  2615.     bsr    pr_prompt
  2616.     move.l    a0,a1
  2617.     bsr    pr_error
  2618. .C    rts            a0=shelline, d0=length
  2619.  
  2620. kill_script
  2621.     move.l    a0,-(sp)
  2622.     tst.b    scflag(a5)
  2623.     beq.s    .A
  2624.     move.l    scaddr(a5),a1
  2625.     move.l    scsize(a5),d0
  2626.     bsr    givemem
  2627. .A    clr.b    scflag(a5)    clean up if no more lines left
  2628.     clr.b    if_flag(a5)    Make sure if structure ends
  2629.     clr.b    goto_flag(a5)    Make sure goto is terminated
  2630.     clr.l    mult_comm_ptr(a5)    break multiple commands
  2631.     move.l    (sp)+,a0
  2632.     rts
  2633.  
  2634. ** SAME AS compare_strings EXCEPT
  2635. ** ALLOWS FOR A1 ENDING IN LF
  2636. lf_compare_strings
  2637.     movem.l    d0-d1/a0-a1,-(sp)
  2638.     bra.s    .A
  2639. .B    tst.b    d0
  2640.     beq.s    .C    RETURN EQ
  2641. .A    move.b    (a0)+,d0
  2642.     move.b    (a1)+,d1
  2643.     bsr    compD1D0nocase
  2644.     beq.s    .B    return NE
  2645.     tst.b    d0
  2646.     bne.s    .C
  2647.     cmp.b    #LF,d1
  2648. .C    movem.l    (sp)+,d0-d1/a0-a1
  2649.     rts
  2650.  
  2651.     
  2652. ** CASE INDEPENDENT STRING COMPARE. COMPARES (A0) TO (A1)
  2653. ** RETURN EQ IF SAME
  2654. compare_strings
  2655.     movem.l    d0-d1/a0-a1,-(sp)
  2656.     bra.s    .A
  2657. .B    tst.b    d0
  2658.     beq.s    .C    RETURN EQ
  2659. .A    move.b    (a0)+,d0
  2660.     move.b    (a1)+,d1
  2661.     bsr    compD1D0nocase
  2662.     beq.s    .B    return NE
  2663. .C    movem.l    (sp)+,d0-d1/a0-a1
  2664.     rts
  2665.  
  2666.     
  2667. * COPY STRING :copys null ending string from A0 to A1, Return with D0=length+1
  2668. cp_string    movem.l a0-a1,-(sp)
  2669.     moveq #0,d0
  2670. cp_str1    addq.l #1,d0
  2671.     move.b (a0)+,(a1)+
  2672.     bne.s cp_str1
  2673.     movem.l (sp)+,a0-a1
  2674.     rts
  2675.  
  2676. *********************************************************
  2677. *Get line of text and seperate into up to 25 parameters    *
  2678. *********************************************************
  2679. get_line    addq.l    #1,count_line(a5)
  2680.     lea    ZShellName(pc),a0
  2681.     move.l    a0,parm1(a5)
  2682.     lea    shelline(a5),a0
  2683.     move.l    mult_comm_ptr(a5),d0 SKIP PROMPT IF SCRIPT OR MULT COMMANDS
  2684.     bne.s    .D
  2685.     tst.b    scflag(a5)
  2686.     bne.s    .B
  2687.     cmp.b    #2,WBflag(a5)
  2688.     bhs    endbground
  2689.     bsr    pr_prompt
  2690. .B    bsr    type_in    NOTE HISTORY STUFF ASSUMES SHELLINE HOLDS THE LINE
  2691.     clr.b    noreview_flag(a5)
  2692.     cmp.b    #';',(a0)        is 1st character a ';'
  2693.     beq.s    get_line
  2694.     cmp.b    #'*',(a0)
  2695.     beq.s    get_line
  2696.     cmp.b    #'#',(a0)
  2697.     beq.s    get_line        do next line if comment
  2698.     cmp.b    #LF,(a0)
  2699.     beq.s    get_line
  2700.     tst.b    scflag(a5)
  2701.     bne.s    .C
  2702.     bsr    handle_logfile
  2703.     bra.s    .C
  2704. .D    move.l    d0,a0        change A0 for multiple commands
  2705. .C    bsr    handle_command_alias    keep A0
  2706.     bsr    parse_line
  2707.     bsr    handle_real_pipes
  2708.     btst    #FLdebug,Flags+3(a5)
  2709.     beq.s    gl16
  2710.     tst.b    scflag(a5)
  2711.     bne.s    gl16
  2712.     move.l    thistask(a5),a1
  2713.     move.l    pr_TaskNum(a1),d0
  2714.     lea    tempbuf(a5),a1
  2715.     bsr    qpr10        get CLI number
  2716.     move.l    #"-> "<<8,(a1)+
  2717.     subq.l    #6,a1
  2718.     bsr    pr_error
  2719.     move.l    a0,a1
  2720.     bsr    pr_error
  2721. gl16    move.l    a0,-(sp)    clear parms
  2722.     lea    parm1(a5),a0
  2723.     lea    endofparms(a5),a1
  2724. .A    clr.l    (a0)+
  2725.     cmp.l    a0,a1
  2726.     bne.s    .A
  2727.     move.l    (sp)+,a0
  2728.     lea    parm1(a5),a2 do 1st parm seperate to establish CLI residue
  2729.     bsr    get_parm
  2730.     tst.l    d2
  2731.     beq    get_line    no command
  2732.     move.l    a0,d7
  2733.     tst.l    d2
  2734.     beq    gl3            if no parms at all
  2735.     tst.b    goto_flag(a5)    CHECK IF IN GOTO SEARCH MODE
  2736.     beq.s    test_ifs
  2737.     move.l    a0,-(sp)
  2738.     lea    labeltx+1(pc),a0
  2739.     bsr    lf_compare_strings
  2740.     bne    skipline
  2741.     move.l    (sp)+,a0
  2742.  
  2743. * Script-IF handling
  2744. test_ifs    tst.b    if_flag(a5)    0 if if encountered earlier
  2745.     beq.s    no_ifs
  2746.     tst.b    if_condition(a5)    0 if condition TRUE
  2747.     beq    no_ifs
  2748. if_false    move.l    a0,-(sp)        push ptr to next
  2749.     lea    elsetx+1(pc),a0
  2750.     bsr    lf_compare_strings
  2751.     bne.s    try_endif
  2752.     not.b    if_condition(a5)    flip condition flag
  2753. skipline    movem.l    (sp)+,d0-d1    get rid of last plus return address
  2754.     bra    chorus
  2755. try_endif    lea    endiftx+1(pc),a0
  2756.     bsr    lf_compare_strings
  2757.     bne.s    skipline
  2758.     clr.b    if_flag(a5)
  2759.     bra.s    skipline
  2760.  
  2761. no_ifs    move.l    a1,(a2)+    save address of parm1
  2762.     lea    CLIbuf(a5),a1
  2763. .C    move.l    a0,CLIbufstart(a5)
  2764.     move.b    (a0)+,d0    skip all preceding spaces
  2765.     cmp.b    #LF,d0
  2766.     beq    .D
  2767.     cmp.b    #" ",d0
  2768.     beq.s    .C
  2769. .B    move.b    d0,(a1)+
  2770.     move.b    (a0)+,d0    copy sudoCLIresidue out
  2771.     cmp.b    #LF,d0        only look for LF end
  2772.     bne.s    .B
  2773. .E    move.b    -(a1),d0    skip all ending spaces
  2774.     cmp.b    #" ",d0
  2775.     beq.s    .E
  2776.     addq.l    #1,a1
  2777. .D    clr.b    (a1)        null end the copy
  2778.     move.l    d7,a0
  2779.     lea    endofparms(a5),a4    establish end of parms block
  2780. gl4    bsr    get_parm        
  2781.     tst.l    d2
  2782.     beq.s    gl3
  2783.     move.l    a1,(a2)+
  2784.     cmp.l    a2,a4        get out if more than 25 parms
  2785.     bne.s    gl4
  2786.     moveq    #118,d0        too many args error
  2787.     bra    pr_galactic
  2788. gl3    rts
  2789.  
  2790. endifz    clr.b    if_flag(a5)
  2791.     moveq    #RETURN_OK,d0
  2792.     rts
  2793. elsez    not.b    if_condition(a5)
  2794.     moveq    #RETURN_OK,d0
  2795.     rts
  2796.  
  2797. *************************
  2798. *        SKIP         *
  2799. *************************
  2800. skipz    move.l    parm2(a5),d1
  2801.     beq    too_less_args
  2802. test_gs    tst.b    scflag(a5)    CAN ONLY GOTO FROM WITHIN SCRIPT
  2803.     bne.s    .A
  2804.     moveq    #RETURN_ERROR,d0
  2805.     rts
  2806. .A    move.l    d1,a0
  2807.     lea    dest_label(a5),a1
  2808. .B    move.b    (a0)+,(a1)+
  2809.     bne.s    .B
  2810.     move.l    scaddr(a5),scptr(a5)  RESET TO START OF SCRIPT
  2811.     move.b    #$ff,goto_flag(a5)
  2812.     clr.b    if_flag(a5)    MAKE SURE IF IS TERMINATED
  2813.     moveq    #RETURN_OK,d0
  2814.     rts
  2815.  
  2816. *************************
  2817. *    LABEL        *     DOES NOTHING IF NOT IN GOTO SEARCH MODE
  2818. *************************
  2819. labelz    tst.b    goto_flag(a5)
  2820.     bne.s    .A
  2821. .B    moveq    #RETURN_OK,D0
  2822.     RTS
  2823. .A    move.l    parm2(a5),d0
  2824.     beq.s    .B
  2825.     move.l    d0,a0
  2826.     lea    dest_label(a5),a1
  2827.     bsr    compare_strings
  2828.     bne    .B
  2829.     clr.b    goto_flag(a5)
  2830.     bra.s    .B
  2831.     
  2832. **************************************************************
  2833. handle_logfile        ;writes date/time and commandline to logfile
  2834.     move.l    loghandle(pc),d0
  2835.     beq.s    logend
  2836.     move.l    a0,a3
  2837.     lea    temp2buf(a5),a2
  2838.     move.l    a2,d1
  2839.     jsr    _LVODateStamp(a6)
  2840.     move.l    a2,a1
  2841.     lea    tempbuf(a5),a2
  2842.     bsr    insert_date
  2843.     move.b    #" ",(a2)+
  2844.     move.l    a2,a1
  2845.     bsr    InsertCLInum2
  2846.     move.b    #" ",(a1)+
  2847.     move.l    a3,a0
  2848. .C    move.b    (a0)+,(a1)+
  2849.     bne.s    .C
  2850.     lea    tempbuf(a5),a0
  2851. write2log        ;write string in a0 to logfile
  2852.     move.l    loghandle(pc),d1
  2853.     move.l    a0,d2
  2854.     moveq    #-1,d3
  2855. .A    addq.l    #1,d3
  2856.     tst.b    (a0)+
  2857.     bne.s    .A
  2858.     jsr    _LVOWrite(a6)
  2859.     move.l    a3,a0
  2860. logend    rts
  2861.     
  2862. *ENTRY A0=shelline    ONLY HANDLES ALIASES OF FIRST KEYWORD.
  2863. handle_command_alias
  2864.     movem.l    d0-d2/a1-a4,-(sp)
  2865.     cmp.b    #LF,(a0)
  2866.     beq    hca_nothing_typed
  2867.     move.l    a0,a1
  2868. .A    cmp.b    #" ",(a1)+    skip preceding spaces
  2869.     beq.s    .A
  2870.     subq.l    #1,a1
  2871.     lea    tempbuf(a5),a3
  2872.     move.b    #LF,(a3)
  2873.     clr.b    1(a3)    must be null end string
  2874.     lea    temp2buf(a5),a2    COPY PARM AT A0 TO SEARCH STR
  2875.     moveq    #78,d1
  2876. .B    move.b    (a1)+,d0
  2877.     bsr    checkendofline
  2878.     beq.s    .D        hca_one_parm
  2879.     cmp.b    #" ",d0
  2880.     beq.s    .D        hca_one_parm
  2881.     move.b    d0,(a2)+
  2882.     dbra    d1,.B
  2883. .D    subq.l    #1,a1
  2884. .E    move.b    (a1)+,(a3)+    COPY FROM SPACE ONWARDS to tempbuf
  2885.     bne.s    .E    WHOLE LINE ENDS IN NULL.
  2886. hca_one_parm
  2887.     clr.b    (a2)    null end search string
  2888.  
  2889. hca_find_it
  2890.     move.l    a0,-(sp)
  2891.     bsr    search_alias
  2892.     move.l    (sp)+,a0
  2893.     beq    hca_nothing_typed
  2894.     move.l    d0,a2
  2895.  
  2896.     lea    4(a2),a2
  2897. .G    tst.b    (a2)+        A2=alias definition
  2898.     bne.s    .G
  2899.     lea    tempbuf(a5),a3    A3=line after alias
  2900.     move.l    a0,a1        A1=shelline ptr
  2901.     moveq    #7,d0
  2902. .F    clr.l    -(sp)        push down eight times 0=no entry.
  2903.     dbra    d0,.F
  2904. .E    move.b    (a2)+,d0        handle %1...$1
  2905.     beq    not_much_of_an_alias
  2906.     cmp.b    #$20,d0        skip spaces
  2907.     beq.s    .E
  2908.     cmp.b    #'%',d0
  2909.     bne.s    no_extra_parms
  2910.     move.b    (a2)+,d0
  2911.     and.w    #$0007,d0        only allow %0 --> %7
  2912. .A    move.b    (a3)+,d1        find where the next param starts
  2913.     cmp.b    #LF,d1
  2914.     beq.s    .C        if no param then pt A3 to lf again
  2915.     cmp.b    #$20,d1
  2916.     beq.s    .A
  2917. .D    lsl.w    #2,d0        x 4
  2918.     move.l    a3,0(sp,d0.w)
  2919.     subq.l    #1,0(sp,d0.w)    put address of param on stack
  2920. .B    move.b    (a3)+,d1        get a3 to pt to next space
  2921.     cmp.b    #LF,d1
  2922.     beq    .C
  2923.     cmp.b    #$20,d1
  2924.     bne.s    .B
  2925. .C    lea    -1(a3),a3        a3 ts to space
  2926.     bra.s    .E        do for more params
  2927. get_next_character
  2928.     move.b    (a2)+,d0
  2929. no_extra_parms
  2930.     cmp.b    #'$',d0
  2931.     bne.s    .A
  2932.     move.b    (a2)+,d0        grab number after $
  2933.     beq.s    not_much_of_an_alias
  2934.     and.w    #$0007,d0
  2935.     lsl.w    #2,d0        x 4
  2936.     move.l    0(sp,d0.w),d1
  2937.     beq.s    get_next_character
  2938.     move.l    d1,a4
  2939. .B    move.b    (a4)+,(a1)+    copy param N
  2940.     cmp.b    #LF,(a4)
  2941.     beq.s    .C
  2942.     cmp.b    #$20,(a4)
  2943.     bne.s    .B
  2944. .C    bra.s    get_next_character
  2945. .A    move.b    d0,(a1)+        copy DEFN -> SHELLINE
  2946.     tst.b    d0
  2947.     bne.s    get_next_character
  2948.  
  2949.     lea    -1(a1),a1
  2950. not_much_of_an_alias
  2951.     lea    32(sp),sp        ** NOTE STACK CHANGE
  2952.     move.l    a1,a4
  2953. .D    move.b    (a3)+,(a1)+    copy tempbuf onto end
  2954.     bne.s    .D
  2955.     moveq    #100,d0
  2956.     bsr    stacktest
  2957.     bne    redirtw
  2958.     bsr    handle_command_alias    recursive alias substitution
  2959.     
  2960. hca_nothing_typed
  2961.     movem.l    (sp)+,d0-d2/a1-a4
  2962.     rts
  2963.  
  2964. search_alias
  2965. * uses temp2buf
  2966. * EXIT: D0 ptr to the associated alias. D1 pts to prior alias
  2967. * RETURN D0=0 IF NOT FOUND.
  2968.     movem.l    d2-d4/a1-a2,-(sp)
  2969.     lea    temp2buf(a5),a1
  2970.     move.l    a1,d2
  2971.     lea    first_alias(a5),a2
  2972.     move.l    a2,d4        NOTE PRIOR ALIAS
  2973.     move.l    (a2),d3
  2974.  
  2975. .D    beq.s    .B
  2976.     move.l    d3,a2
  2977.     lea    4(a2),a2    A2=current alias name
  2978.     move.l    d2,a1        A1=name to match
  2979.     bra.s    .C
  2980. .A    tst.b    d0
  2981.     beq.s    .B
  2982. .C    move.b    (a1)+,d0
  2983.     move.b    (a2)+,d1
  2984.     bsr    compD1D0locale
  2985.     beq.s    .A
  2986.  
  2987.     move.l    d3,a2
  2988.     move.l    d3,d4
  2989.     move.l    (a2),d3
  2990.     bra.s    .D
  2991. .B    move.l    d4,d1
  2992.     move.l    d3,d0
  2993.     movem.l    (sp)+,d2-d4/a1-a2
  2994.     rts
  2995.  
  2996.     
  2997. * GET PARM line pted to by A0
  2998. * LINE MUST END IN LF THEN 0
  2999. * returns A1 pointing to the address where the parm starts
  3000. * puts a 0 over the space or lf where it ends .A0 pts to next bit on end
  3001. * return d2=0 if got all possible commands from line
  3002. get_parm    moveq    #$20,d2    D2=delimiter
  3003. get_parm1    move.l    a0,a1    ;make sure we can get the address before
  3004.     move.b    (a0)+,d1    ;skip spaces
  3005.     beq.s    last_parm2
  3006.     cmp.b    #$20,d1
  3007.     beq.s    get_parm1
  3008.     cmp.b    #$9,d1        skip tabs
  3009.     beq.s    get_parm1
  3010.     cmp.b    #LF,d1        handle idiots who type spaces at end of line
  3011.     beq.s    last_parm
  3012.     cmp.b    #'"',d1        handle double quotes
  3013.     bne.s    gp2
  3014.     addq.l    #1,a1
  3015.     moveq    #'"',d2    SET DELIMITER = "
  3016.     bra.s    gp2
  3017. gp4    cmp.b    #LF,(a0)    handle idiots who type \ at end of line
  3018.     beq.s    gp3
  3019.     addq.l    #1,a0        make sure pts to after quotes d1 is dummy
  3020. gp2    move.b    (a0)+,d1    a0 pts to after the space on exit
  3021.     cmp.b    #LF,d1
  3022.     beq.s    gp3
  3023.     cmp.b    #$5c,d1        allow for \" (nested quotes)
  3024.     beq.s    gp4
  3025.     cmp.b    d2,d1
  3026.     bne.s    gp2
  3027.     clr.b    -1(a0)        make sure last byte is 0
  3028.     rts
  3029. last_parm    clr.b -1(a0)
  3030. last_parm2    moveq #0,d2    ;signify the end
  3031.         rts
  3032. gp3    subq.l    #1,a0    if ends in LF then dont null end, catch that next time
  3033.     rts
  3034.  
  3035. **************************************************
  3036. close_redirection
  3037.     tst.b    redirect_in(a5)
  3038.     beq.s    .A
  3039.     tst.l    PipeTask(a5)        handle real pipe
  3040.     beq.s    .G
  3041. .H    move.l    inhandle(a5),d1
  3042.     lea    tempbuf(a5),a0
  3043.     move.l    a0,d2
  3044.     move.l    #2*SHELLINE_SIZE,d3
  3045.     jsr    _LVORead(a6)        read till pipe_in is empty
  3046.     tst.l    d0
  3047.     bmi.s    .G
  3048.     bne.s    .H
  3049. .G    move.l    thistask(a5),a0
  3050.     move.l    pr_CIS(a0),d1
  3051.     move.l    stdin(a5),pr_CIS(a0)    restore old stdin
  3052.     move.l    stdin(a5),inhandle(a5)
  3053.     jsr    _LVOClose(a6)
  3054. .A    tst.b    redirect_out(a5)
  3055.     beq.s    .B
  3056.     move.l    thistask(a5),a0
  3057.     move.l    pr_COS(a0),d1
  3058.     move.l    stdout(a5),pr_COS(a0)    restore old stdout
  3059.     move.l    stdout(a5),outhandle(a5)    
  3060.     jsr    _LVOClose(a6)
  3061.     tst.l    MPipePtr(a5)
  3062.     beq.s    .B
  3063.     movem.l    d2-d7/a2-a4,-(sp)
  3064.     sub.l    a3,a3
  3065.     bsr    viewbuffer        >M show output with more
  3066.     movem.l    (sp)+,d2-d7/a2-a4
  3067.     clr.l    MPipePtr(a5)
  3068. .B    clr.w    redirect_in(a5)        clear redirect_in and redirect_out
  3069.  
  3070.     btst    #FLpipe,Flags+2(a5)
  3071.     bne.s    .E
  3072.     lea    pipe_in(a5),a2        handle pseudo pipe
  3073.     tst.b    (a2)
  3074.     beq.s    .C
  3075.     move.l    a2,d1
  3076.     jsr    _LVODeleteFile(a6)    delete temporary file
  3077. .C    lea    pipe_out(a5),a1
  3078. .D    move.b    (a1)+,(a2)+        copy pipe_out to pipe_in
  3079.     bne.s    .D
  3080.     bra.s    .F
  3081.  
  3082. .E    tst.b    pipe_out(a5)        handle real pipe
  3083.     beq.s    .F
  3084.     move.l    4.w,a6
  3085.     moveq    #0,d0
  3086.     bset    #SIGBREAKB_CTRL_E,d0
  3087.     jsr    _LVOWait(a6)    wait for CTRL-F or till task returns
  3088.     move.l    dosbase(a5),a6
  3089. .F    clr.b    pipe_out(a5)        no pipe_out
  3090.     rts
  3091.  
  3092. *************************************************
  3093. *    This is the command line parser    V2.8    *
  3094. *    Entry: A0 points to shelline        *
  3095. *************************************************
  3096. parse_line
  3097.     move.l    a0,-(sp)
  3098.     move.l    a0,-(sp)
  3099.     lea    pipe_in(a5),a2
  3100.     tst.b    (a2)
  3101.     beq.s    .A
  3102.     bsr    re_in3
  3103. .A    move.l    (sp)+,a4    a4=new commandline
  3104.     move.l    a4,a3        a3=old commandline
  3105.     move.l    a4,d4        d5 used by redirect
  3106.     addq.l    #1,d4        d4=start of commandline
  3107. parseloop
  3108.     move.b    (a3)+,d0
  3109.     move.b    d0,(a4)+
  3110.     cmp.b    #$5c,d0        IS IT BACKSLASH \ ?
  3111.     bne.s    psquote
  3112.     tst.b    pipe_out(a5)
  3113.     bne.s    psquote
  3114. .C    move.b    (a3)+,d0    skip next char and check for LF
  3115.     cmp.b    #";",d0
  3116.     beq.s    .G
  3117.     cmp.b    #"|",d0
  3118.     beq.s    .G
  3119.     cmp.b    #"<",d0
  3120.     beq.s    .G
  3121.     cmp.b    #">",d0
  3122.     beq.s    .G
  3123.     move.l    d4,d1
  3124.     addq.l    #1,d1
  3125.     cmp.l    d1,a3        start of line -> alias-disabling
  3126.     bne.s    .H
  3127. .G    subq.l    #1,a4        overwrite \ if followed by ; | < >
  3128. .H    move.b    d0,(a4)+
  3129.     cmp.b    #$5c,d0        double backslash ?
  3130.     beq.s    .C
  3131.     bra    pschklf
  3132. psquote    cmp.b    #'"',d0        IGNORE ; AND | BETWEEN QUOTES
  3133.     bne.s    psmulti
  3134.     cmp.l    d4,a4        start of line ?
  3135.     beq.s    .D
  3136.     cmp.b    #" ",-2(a4)    space before starting quote ?
  3137.     beq.s    .D
  3138.     cmp.b    #"=",-2(a4)    = before starting quote ? (for AmigaDOS)
  3139.     bne    redspc
  3140. .D    move.b    (a3)+,d0
  3141.     move.b    d0,(a4)+
  3142.     cmp.b    #LF,d0        missing ending quote ?
  3143. .A    beq    redquo
  3144.     cmp.b    #$5c,-2(a4)
  3145.     beq.s    .D
  3146.     cmp.b    #'"',d0
  3147.     bne.s    .D
  3148.     cmp.b    #" ",(a3)    space behind ending quote ?
  3149.     beq.s    psmulti
  3150.     cmp.b    #LF,(a3)    except at end of line
  3151.     bne    redspc
  3152. psmulti    cmp.b    #";",d0        CHECK MULTI CMD OR PIPE
  3153.     bne.s    .A
  3154.     move.b    #LF,-1(a4)    replace ; with LF
  3155.     tst.l    PipeTask(a5)    is it a pipe task ?
  3156.     bne.s    pslend        yes: no mult comms
  3157.     move.l    a4,mult_comm_ptr(a5)
  3158.     bra.s    psexit
  3159. .A    cmp.b    #"|",d0
  3160.     beq    handle_pipes
  3161. psredir    cmp.b    #" ",-2(a4)    look for space before < or >
  3162.     bne.s    .F
  3163.     tst.b    pipe_out(a5)
  3164.     bne.s    .F
  3165.     lea    redir_tx(pc),a0    CHECK REDIRECTION
  3166.     move.l    a0,parm1(a5)
  3167.     cmp.b    #'>',d0
  3168.     bne.s    .I
  3169.     bsr    redir_out
  3170.     bra.s    .C
  3171. .I    cmp.b    #'<',d0
  3172.     bne.s    .C
  3173.     bsr    redir_in
  3174. .C    lea    ZShellName(pc),a0
  3175.     move.l    a0,parm1(a5)
  3176. .F
  3177. pschklf    cmp.b    #LF,d0        there must be a LF at end
  3178.     bne    parseloop
  3179. pslend    clr.l    mult_comm_ptr(a5)
  3180.     clr.b    pipe_count(a5)
  3181. psexit    move.b    (a3)+,(a4)+    copy other multi commands
  3182.     bne.s    psexit
  3183.     lea    pipe_out(a5),a2
  3184.     tst.b    (a2)
  3185.     beq.s    .A
  3186.     bsr    re_out2        output redirect pipes
  3187. .A    move.l    (sp)+,a0
  3188.     rts
  3189.  
  3190. checkendofline
  3191.     cmp.b    #";",d0
  3192.     beq.s    .D
  3193.     cmp.b    #"|",d0
  3194.     beq.s    .D
  3195.     cmp.b    #LF,d0        look for end of line
  3196. .D    rts
  3197.  
  3198. redquo    moveq    #119,d0
  3199.     bra.s    rederr2
  3200. rederr    jsr    _LVOIoErr(a6)    print DOS error
  3201. rederr2    bsr    pr_DOSerr    print error in D0
  3202.     bra.s    redirtw
  3203.  
  3204. redspc    lea    nospace_tx(pc),a0
  3205.     bra.s    reditw
  3206. redir_twice
  3207.     lea    redirtwice(pc),a0
  3208. reditw    bsr    PrintError
  3209. redirtw    move.l    thistask(a5),a1
  3210.     bsr    SetSignalE
  3211.     move.l    a4,d2
  3212. .A    move.b    (a3)+,(a4)+    copy other multi commands
  3213.     bne.s    .A
  3214.     lea    shelline(a5),a1
  3215.     move.l    mult_comm_ptr(a5),d0
  3216.     beq.s    .B
  3217.     move.l    d0,a1
  3218. .B    sub.l    a1,d2
  3219.     bsr    pr_error
  3220.     lea    tempbuf(a5),a0
  3221.     move.l    a0,a1
  3222.     tst.l    d2
  3223.     beq.s    .D
  3224.     subq.l    #1,d2
  3225.     bra.s    .D
  3226. .C    move.b    #" ",(a0)+
  3227. .D    dbra    d2,.C
  3228.     move.b    #"^",(a0)+
  3229.     move.b    #LF,(a0)+
  3230.     clr.b    (a0)
  3231.     bsr    pr_error
  3232.     clr.b    pipe_out(a5)
  3233.     clr.l    mult_comm_ptr(a5)
  3234.     bra    galactic
  3235.  
  3236. redir_in
  3237.     tst.b    redirect_in(a5)
  3238.     bne.s    redir_twice
  3239.     cmp.b    #">",(a3)
  3240.     beq.s    redir_both
  3241. re_in2    bsr    copy_redirector
  3242. re_in3    move.l    #MODE_OLDFILE,d2
  3243.     bsr    redir_open2
  3244.     bsr    ChngIn
  3245.     rts
  3246. redir_both
  3247.     tst.b    redirect_out(a5)
  3248.     bne.s    redir_twice
  3249.     bsr    re_in2
  3250.     lsl.l    #2,d0
  3251.     move.l    d0,a0
  3252.     move.l    thistask(a5),a1
  3253.     move.l    pr_ConsoleTask(a1),-(sp)
  3254.     move.l    fh_Type(a0),pr_ConsoleTask(a1)
  3255.     beq.s    .A
  3256.     lea    star(pc),a2
  3257. .A    addq.l    #1,a4
  3258.     bsr    re_out2
  3259.     move.l    thistask(a5),a1
  3260.     move.l    (sp)+,pr_ConsoleTask(a1)
  3261.     rts
  3262. redir_out
  3263.     tst.b    redirect_out(a5)
  3264.     bne    redir_twice
  3265.     cmp.b    #">",(a3)
  3266.     beq.s    redir_append
  3267.     bsr    copy_redirector
  3268.     move.l    a2,a0
  3269.     move.b    #"M",d0
  3270.     bsr    CheckOneChar
  3271.     bne.s    re_out2
  3272. .A    clr.b    (a2)    redir to MORE, send to nil:
  3273.     move.l    ReviewPtr(a5),MPipePtr(a5)
  3274. re_out2    move.l    #MODE_NEWFILE,d2
  3275.     bsr    redir_open2
  3276.     bsr    ChngOut
  3277.     rts
  3278. redir_append
  3279.     move.l    #MODE_READWRITE,d2
  3280.     bsr    redir_open
  3281.     bsr    ChngOut
  3282.     move.l    d0,d1
  3283.     moveq    #0,d2    set position
  3284.     moveq    #1,d3    set mode
  3285.     jsr    _LVOSeek(a6)
  3286.     rts
  3287.  
  3288. ChngIn    move.l    thistask(a5),a0
  3289.     move.l    d0,pr_CIS(a0)    MAKE STDIN DIFFERENT.
  3290.     move.l    d0,inhandle(a5)
  3291.     addq.b    #1,redirect_in(a5)
  3292.     rts
  3293. ChngOut    move.l    thistask(a5),a0
  3294.     move.l    d0,pr_COS(a0)
  3295.     move.l    d0,outhandle(a5)
  3296.     addq.b    #1,redirect_out(a5)
  3297.     rts
  3298.  
  3299. redir_open
  3300.     bsr    copy_redirector
  3301. redir_open2
  3302.     tst.b    (a2)        null string opens NIL:
  3303.     bne.s    .B
  3304.     lea    connil(pc),a2
  3305. .B    move.l    a2,a0
  3306.     move.b    #"W",d0        "w" opens default window
  3307.     bsr    CheckOneChar
  3308.     bne.s    .C
  3309.     lea    conname(pc),a2
  3310.     move.l    windowname(a5),d0
  3311.     beq.s    .C
  3312.     move.l    d0,a2    
  3313. .C    move.l    a2,d1
  3314.     jsr    _LVOOpen(a6)    open file
  3315.     tst.l    d0
  3316.     beq    rederr
  3317.     move.l    d5,a3    skip redir-name in cmdline
  3318. .A    subq.l    #1,a4
  3319.     cmp.b    #" ",-1(a4)
  3320.     beq.s    .A
  3321.     rts
  3322.  
  3323. * ENTRY    A3 pts to redirection symbol
  3324. *    A4 pts to new shelline
  3325. * EXIT    A2 pts to null end string in tempbuf
  3326. *    A3 is increased, so that redir name is deleted from shelline
  3327. *    A4 is decreased to delete space before redir
  3328. copy_redirector
  3329.     lea    tempbuf(a5),a2
  3330.     move.l    a2,a0
  3331.     move.l    a3,a1        save start of redirection string
  3332.     cmp.b    #">",(a1)    handle append redirection properly
  3333.     bne.s    .B
  3334.     addq.l    #1,a1
  3335. .B    cmp.b    #$22,(a1)    is string enclosed in quotes ?
  3336.     bne.s    .A
  3337.     addq.l    #1,a1        skip first quote
  3338.     move.b    #$22,(a0)+    remember quotes
  3339.     addq.l    #1,a2
  3340. .C    move.b    (a1)+,d0
  3341.     cmp.b    #$22,d0        look for last quote
  3342.     beq.s    cpredsp
  3343.     cmp.b    #LF,d0        missing last quote ?
  3344.     beq    redquo
  3345.     move.b    d0,(a0)+    copy newstdin/out to nonstdin/out
  3346.     bra.s    .C
  3347. .A    move.b    (a1)+,d0
  3348.     cmp.b    #" ",d0        look for ending space
  3349.     beq.s    cpredlf
  3350.     bsr    checkendofline
  3351.     beq.s    cpredlf
  3352.     move.b    d0,(a0)+    copy newstdin/out to nonstdin/out
  3353.     bra.s    .A
  3354.  
  3355. cpredlf    subq.l    #1,a1
  3356.     cmp.b    #$22,-1(a1)
  3357.     beq    redquo
  3358. cpredsp    move.l    a1,d5
  3359.     clr.b    (a0)+    A0 should point to after the space or lf
  3360.     rts
  3361.  
  3362. *** PIPES V2.7 ***
  3363. handle_pipes
  3364.     btst    #FLpipe,Flags+2(a5)
  3365.     beq.s    .D
  3366.     tst.b    pipe_out(a5)
  3367.     bne    parseloop    check for next multi cmd or end of line
  3368. .D    move.b    #LF,-1(a4)        replace | with LF
  3369.     addq.b    #1,pipe_count(a5)
  3370.     tst.b    redirect_out(a5)
  3371.     bne    redir_twice
  3372.     move.l    a4,mult_comm_ptr(a5)
  3373.     lea    pipe_out(a5),a1
  3374.     lea    devpipe(pc),a2
  3375.     btst    #FLpipe,Flags+2(a5)
  3376.     bne.s    .A
  3377.     lea    devtemp(pc),a2
  3378. .A    move.b    (a2)+,(a1)+    copy "PIPE:" or "T:" to pipe_out
  3379.     bne.s    .A
  3380.     subq.l    #1,a1
  3381.     bsr    InsertCLInum
  3382.     btst    #FLpipe,Flags+2(a5)    real pipe ?
  3383.     bne.s    .C
  3384.     move.b    pipe_count(a5),d0    append pipe number for pseudo pipes
  3385.     bsr    qpr10
  3386.     clr.b    (a1)
  3387.     bra    psexit        do same like multi cmds
  3388. .C    clr.b    (a1)
  3389.     bra    parseloop    check for next multi cmd or end of line
  3390.  
  3391. handle_real_pipes
  3392.     btst    #FLpipe,Flags+2(a5)
  3393.     beq.s    .B
  3394.     tst.b    pipe_out(a5)
  3395.     beq.s    .B
  3396.     movem.l    d2-d7/a0-a4,-(sp)
  3397.     move.l    a0,a1
  3398. .C    cmp.b    #LF,(a1)+
  3399.     bne.s    .C
  3400.     lea    tempbuf(a5),a2        create parms for new task
  3401.     move.l    a2,parm2(a5)
  3402.     move.l    #"-w*"<<8,(a2)+
  3403.     move.l    a2,parm3(a5)
  3404.     move.w    #"-c",(a2)+
  3405.     clr.l    parm4(a5)
  3406. .F    move.b    (a1)+,(a2)+
  3407.     bne.s    .F
  3408.     clr.b    -2(a2)        clear LF
  3409.     move.l    4.w,a6
  3410.     moveq    #0,d0
  3411.     moveq    #0,d1
  3412.     bset    #SIGBREAKB_CTRL_E,d1
  3413.     jsr    _LVOSetSignal(a6)    clear signal CTRL-F
  3414.     move.l    dosbase(a5),a6
  3415.     moveq    #3,d7
  3416.     bsr    create_new_cli        create new task for real pipes
  3417.     beq.s    .A
  3418.     moveq    #16,d1
  3419.     bsr    GuruIt            creation of task failed
  3420.     lea    shelline(a5),a4
  3421.     bra    redirtw
  3422. .A    movem.l    (sp)+,d2-d7/a0-a4
  3423. .B    rts
  3424.  
  3425. endbground
  3426.     move.l    PipeTask(a5),d0
  3427.     beq.s    .A        started with RUN
  3428.     move.l    d0,a1        task real pipe started from
  3429.     bsr    SetSignalE    tell it to end
  3430. .A    bra    ExitZShell
  3431.  
  3432. SetSignalE        ;a1=taskaddress
  3433.     move.l    4.w,a6
  3434.     moveq    #0,d0
  3435.     bset    #SIGBREAKB_CTRL_E,d0
  3436.     jsr    _LVOSignal(a6)
  3437.     move.l    dosbase(a5),a6
  3438.     rts
  3439.  
  3440. ******************************
  3441. * Iconify Shell        V2.3 *
  3442. ******************************
  3443. WaitAppIcon
  3444.     movem.l    d2-d7/a2-a4,-(sp)
  3445.     clr.b    tempbuf(a5)
  3446. ;    cmp.w    #36,kickver(a5)
  3447. ;    blo    .G
  3448.     bsr    KillAppWin
  3449.     bsr    raw_off
  3450.     bsr    clkof2
  3451.     bsr    CloseWin
  3452.  
  3453.     tst.l    diskobj(a5)
  3454.     bne.s    .I
  3455.     bsr    OpenIconLib
  3456.     beq.s    .A
  3457.     moveq    #3,d0
  3458.     jsr    _LVOGetDefDiskObject(a6)
  3459.     move.l    d0,diskobj(a5)
  3460.     beq    .A
  3461. .I    bsr    OpenWBLib
  3462.     beq    .A
  3463.     moveq    #0,d0    opened workbench.library
  3464.     moveq    #0,d1
  3465.     move.l    app_name(a5),a0
  3466.     move.l    thistask(a5),a1
  3467.     lea    pr_MsgPort(a1),a1
  3468.     move.l    a1,d3
  3469.     sub.l    a2,a2
  3470.     move.l    diskobj(a5),a3
  3471.     sub.l    a4,a4
  3472.     jsr    _LVOAddAppIconA(a6)    add appicon
  3473.     move.l    d0,d2
  3474.     beq.s    .B
  3475.     move.l    4.w,a6
  3476. .C    move.l    d3,a0
  3477.     jsr    _LVOWaitPort(a6)    wait for one message
  3478.     bsr    GetAppIMsgs
  3479.     move.l    wbbase(a5),a6
  3480.     move.l    d2,a0
  3481.     jsr    _LVORemoveAppIcon(a6)    remove appicon
  3482. .B    bsr    GetAppIMsgs
  3483.  
  3484. .A    move.l    dosbase(a5),a6
  3485.     tst.b    openwin_flag(a5)    restore window
  3486.     beq.s    .G
  3487.     move.l    thistask(a5),a3
  3488.     move.l    CLIptr(a5),a2
  3489.     move.l    windowname(a5),d1
  3490.     clr.b    openwin_flag(a5)
  3491.     bsr    OpenWin
  3492.     beq    ExitZShell
  3493.     bsr    SetConHandles
  3494.     bsr    InitAppWin
  3495.     tst.b    memclk_flag(a5)
  3496.     beq.s    .G
  3497.     bsr    clkon
  3498. .G    movem.l    (sp)+,d2-d7/a2-a4
  3499.     rts
  3500.  
  3501. GetAppIMsgs
  3502.     move.l    4.w,a6
  3503. .B    move.l    d3,a0
  3504.     jsr    _LVOGetMsg(a6)        get all messages
  3505.     tst.l    d0
  3506.     beq.s    .A
  3507.     move.l    d0,a2
  3508.     cmp.w    #8,am_Type(a2)
  3509.     bne.s    .B
  3510.     bsr    ProcessApp
  3511.     move.l    a2,a1
  3512.     jsr    _LVOReplyMsg(a6)    reply them
  3513.     bra.s    .B
  3514. .A    rts
  3515.  
  3516. ProcessApp    ;Message in a2
  3517.     movem.l    a2-a6,-(sp)
  3518.     move.l    am_NumArgs(a2),d0
  3519.     move.l    am_ArgList(a2),a0
  3520.     lea    tempbuf(a5),a2
  3521.     bra.s    .D
  3522.  
  3523. .E    move.l    a2,a3
  3524.     move.l    (a0)+,d1    process all args
  3525.     beq.s    .C        get name from lock to dir
  3526.     movem.l    d0-d3/a0/a3,-(sp)
  3527.     move.l    dosbase(a5),a6
  3528.     jsr    _LVODupLock(a6)
  3529.     move.l    a2,a0
  3530.     bsr    eval_full_path
  3531.     jsr    _LVOUnLock(a6)
  3532. .A    tst.b    (a2)+
  3533.     bne.s    .A
  3534.     subq.l    #1,a2
  3535.     cmp.b    #":",-1(a2)
  3536.     beq.s    .B
  3537.     move.b    #"/",(a2)+    /-end path
  3538. .B    movem.l    (sp)+,d0-d3/a0/a3
  3539.  
  3540. .C    move.l    (a0)+,d1    get filename
  3541.     beq.s    .D
  3542.     move.l    d1,a1
  3543.     bsr    addstring
  3544.     bsr.s    MaybeInsertQuote
  3545.     move.b    #" ",(a2)+    space-end
  3546.  
  3547. .D    dbra    d0,.E
  3548.     clr.b    (a2)
  3549.     movem.l    (sp)+,a2-a6
  3550.     rts
  3551.  
  3552. MaybeInsertQuote    ;a3=start, a2=end of string
  3553.     move.l    a3,a1    changes only d1, a1, a2
  3554.     moveq    #0,d1    Inserts quotes if strings contains spaces
  3555. .G    cmp.b    #" ",(a1)+
  3556.     bne.s    .F
  3557.     moveq    #1,d1    space found
  3558. .F    cmp.l    a1,a2
  3559.     bne.s    .G
  3560.     tst.l    d1
  3561.     beq.s    .H    jump if no spaces
  3562.     addq.l    #1,a2
  3563.     move.b    #$22,(a2)+    append last quote
  3564. .I    move.b    -1(a1),(a1)    insert one char
  3565.     subq.l    #1,a1
  3566.     cmp.l    a1,a3
  3567.     bne.s    .I
  3568.     move.b    #$22,(a1)    store starting quote
  3569. .H    rts
  3570.  
  3571. ** evaluate entire name associated with lock in D0, store string in A0
  3572. ** Return D1 = last lock to unlock
  3573. ** Reg usage: d0,d1,d2,d3,a0,a1,a3 (must not use A2)
  3574.  
  3575. OpenIconLib
  3576.     move.l    iconbase(a5),d0
  3577.     bne.s    .A
  3578.     move.l    4.w,a6
  3579.     lea    iconname(pc),a1
  3580.     jsr    _LVOOldOpenLibrary(a6)    icon-library
  3581.     move.l    d0,iconbase(a5)
  3582. .A    move.l    d0,a6
  3583.     rts
  3584.  
  3585. OpenWBLib
  3586.     move.l    wbbase(a5),d0
  3587.     bne.s    .A
  3588.     move.l    4.w,a6
  3589.     lea    wbname(pc),a1
  3590.     jsr    _LVOOldOpenLibrary(a6)
  3591.     move.l    d0,wbbase(a5)
  3592. .A    move.l    d0,a6
  3593.     rts
  3594.  
  3595. **********************************************
  3596. * Create CLI-Interface-Structure    V2.0 *
  3597. **********************************************
  3598. CreateCLI
  3599.     clr.b    WBflag(a5)    0=WB or CLI/1=newcli/2=run/3=pipe
  3600.     move.l    thistask(a5),a3
  3601.     move.l    pr_WindowPtr(a3),d0
  3602.     move.l    d0,oldwindowptr(a5)    preserve old winptr
  3603.     move.l    d0,windowptr(a5)
  3604.     bsr    GetWindowPtr
  3605.     tst.b    CLIflag(a5)
  3606.     beq    CCli3
  3607.     clr.l    EntryA0(a5)        started from WB
  3608.     move.l    #64+$28+$50,d0
  3609.     bsr    iwantcleanmem        memory for CLI
  3610.     moveq    #1,d1
  3611.     tst.l    d0
  3612.     beq    CCli2
  3613.     move.l    d0,a2
  3614.     lsr.l    #2,d0
  3615.     move.l    d0,pr_CLI(a3)
  3616.     move.l    dl_Root(a6),a0
  3617.     move.l    (a0),a0
  3618.     add.l    a0,a0
  3619.     add.l    a0,a0
  3620.     moveq    #0,d2
  3621.     move.l    (a0),d0
  3622.     subq.l    #1,d0
  3623. .C    addq.l    #1,d2
  3624.     addq.l    #4,a0
  3625.     tst.l    (a0)        look for free CLI-Number
  3626.     dbeq    d0,.C
  3627.     moveq    #2,d1
  3628.     tst.l    (a0)
  3629.     bne    CCli2
  3630.     lea    pr_MsgPort(a3),a1
  3631.     move.l    a1,(a0)
  3632.     move.l    d2,pr_TaskNum(a3)
  3633.     moveq    #10,d0
  3634.     move.l    d0,cli_FailLevel(a2)
  3635.     moveq    #-1,d0
  3636.     move.l    d0,cli_Interactive(a2)
  3637.     move.l    #1000,cli_DefaultStack(a2)    1000 LONGs
  3638.     move.l    pr_FileSystemTask(a3),filesys_old(a5)
  3639.     lea    64(a2),a0
  3640.     move.l    a0,d0
  3641.     lsr.l    #2,d0
  3642.     move.l    d0,cli_CommandFile(a2)
  3643.     lea    64+$28(a2),a0
  3644.     move.l    a0,d0
  3645.     lsr.l    #2,d0
  3646.     move.l    d0,cli_CommandName(a2)
  3647.     IFD    DEBUG
  3648.     tst.l    wb_msg(a5)
  3649.     beq    CreateCLI2    no WB-Msg -> CreateCLI2
  3650.     ENDC
  3651.     move.l    wb_msg(a5),a0
  3652.     tst.l    sm_Process(a0)
  3653.     beq    CreateCLI3    newcli/run -> CreateCLI3
  3654.     move.l    sm_ArgList(a0),a1
  3655.     moveq    #2,d0
  3656.     cmp.l    sm_NumArgs(a0),d0
  3657.     bhi.s    .A        Project ?
  3658.     addq.l    #8,a1
  3659. .A    move.l    (a1),a0        Lock on Current Dir
  3660.     moveq    #3,d1
  3661.     move.l    a0,d0
  3662.     beq    CCli2
  3663.     move.l    a0,d1
  3664.     move.l    dosbase(a5),a6
  3665.     jsr    _LVODupLock(a6)        WB wants to free its own lock
  3666.     bsr    SetCurrentDir
  3667.     move.l    4.w,a6
  3668.     lea    wbenchtx(pc),a1
  3669.     jsr    _LVOFindTask(a6)
  3670.     tst.l    d0
  3671.     beq.s    .E
  3672.     move.l    d0,a0
  3673.     tst.l    pr_CLI(a0)
  3674.     beq.s    .E
  3675.     move.l    dosbase(a5),a6
  3676.     bsr    CopyPaths    copy paths from workbench
  3677. .E    bsr    OpenIconLib
  3678.     moveq    #4,d1
  3679.     tst.l    d0
  3680.     beq    CCli2
  3681.     move.l    d0,a4
  3682.     move.l    wb_msg(a5),a0
  3683.     move.l    sm_ArgList(a0),a1
  3684.     moveq    #2,d0
  3685.     cmp.l    sm_NumArgs(a0),d0
  3686.     bhi.s    .B            Project ?
  3687.     move.l    12(a1),d0
  3688.     beq.s    .B
  3689.     move.l    d0,EntryA0(a5)        Name of Project as Script
  3690.     addq.l    #8,a1
  3691. .B    move.l    4(a1),a0        Name of Process
  3692.     jsr    _LVOGetDiskObject(a6)
  3693.     moveq    #5,d1
  3694.     move.l    d0,diskobj(a5)
  3695.     beq    CCli2
  3696.     move.l    d0,a0
  3697.     moveq    #0,d0
  3698.     bset    #31,d0        unset icon position
  3699.     move.l    d0,$3a(a0)    CurrentX
  3700.     move.l    d0,$3e(a0)    CurrentY
  3701.     move.b    #8,$30(a0)    Type=AppIcon
  3702.     move.l    do_ToolTypes(a0),d3    d3=ToolTypes
  3703. checktooltypes
  3704.     move.l    d3,a0
  3705.     lea    xpostool(pc),a1
  3706.     jsr    _LVOFindToolType(a6)    Look for XPOS-ToolType
  3707.     tst.l    d0
  3708.     beq.s    .G
  3709.     move.l    d0,a1
  3710.     bsr    convert_ASCII_to_num
  3711.     beq.s    .G
  3712.     move.l    diskobj(a5),a0
  3713.     move.l    d0,$3a(a0)
  3714. .G    move.l    d3,a0
  3715.     lea    ypostool(pc),a1
  3716.     jsr    _LVOFindToolType(a6)    Look for YPOS-ToolType
  3717.     tst.l    d0
  3718.     beq.s    .E
  3719.     move.l    d0,a1
  3720.     bsr    convert_ASCII_to_num
  3721.     beq.s    .E
  3722.     move.l    diskobj(a5),a0
  3723.     move.l    d0,$3e(a0)
  3724. .E    move.l    d3,a0
  3725.     lea    nametool(pc),a1
  3726.     jsr    _LVOFindToolType(a6)    Look for ICONNAME-ToolType
  3727.     tst.l    d0
  3728.     beq.s    .C
  3729.     move.l    d0,app_name(a5)
  3730. .C    move.l    d3,a0
  3731.     lea    iconifytool(pc),a1
  3732.     jsr    _LVOFindToolType(a6)    Look for ICONIFY-ToolType
  3733.     tst.l    d0
  3734.     beq.s    .B
  3735.     bset    #FLappicon,Flags+3(a5)
  3736.     movem.l    d2-d5/a6,-(sp)
  3737.     moveq    #0,d4
  3738.     moveq    #0,d5
  3739.     bsr    WaitAppIcon
  3740.     movem.l    (sp)+,d2-d5/a6
  3741. .B    move.l    d3,a0
  3742.     lea    screentool(pc),a1
  3743.     jsr    _LVOFindToolType(a6)    Look for SCREEN-ToolType
  3744.     move.l    d0,pubname(a5)
  3745.     move.l    d3,a0
  3746.     lea    wintool(pc),a1
  3747.     jsr    _LVOFindToolType(a6)    Look for WINDOW-ToolType
  3748.     lea    conname(pc),a0
  3749.     tst.l    d0
  3750.     beq.s    .D
  3751.     move.l    d0,a0
  3752. .D    move.l    a0,d1
  3753.     move.l    dosbase(a5),a6
  3754.     bsr    OpenWin            Open Window
  3755.     beq    CCli2a
  3756.     move.l    d3,a0
  3757.     lea    scripttool(pc),a1
  3758.     move.l    a4,a6
  3759.     jsr    _LVOFindToolType(a6)    Look for SCRIPT-ToolType
  3760.     tst.l    EntryA0(a5)    project ?
  3761.     bne.s    .F
  3762.     move.l    d0,EntryA0(a5)
  3763. .F    move.l    d3,a0
  3764.     lea    norawtool(pc),a1
  3765.     jsr    _LVOFindToolType(a6)    Look for NORAW-ToolType
  3766.     tst.l    d0
  3767.     beq.s    .A
  3768.     bclr    #FLraw,Flags+2(a5)
  3769. .A    move.l    d3,a0
  3770.     lea    helptool(pc),a1
  3771.     jsr    _LVOFindToolType(a6)    Look for HELPMAN-ToolType
  3772.     tst.l    d0
  3773.     beq.s    .H
  3774.     move.l    d0,online_help(a5)
  3775. .H    move.l    d3,a0
  3776.     lea    commandtool(pc),a1
  3777.     jsr    _LVOFindToolType(a6)    Look for COMMAND-ToolType
  3778.     move.l    d0,d2
  3779.     bsr    Com2Script
  3780. CCli1    move.l    dosbase(a5),a6
  3781.     moveq    #0,d0
  3782.     rts
  3783. CCli2    bsr    GuruIt
  3784. CCli2a    move.l    dosbase(a5),a6
  3785.     moveq    #-1,d0
  3786.     rts
  3787.  
  3788. CCli3    move.l    pr_COS(a3),outhandle(a5)    started from CLI
  3789.     move.l    pr_CurrentDir(a3),d1
  3790.     bne.s    .D
  3791.     moveq    #-2,d2
  3792.     jsr    _LVOLock(a6)
  3793.     tst.l    d0
  3794.     beq    .D
  3795.     bsr    SetCurrentDir
  3796. .D    move.l    EntryA0(a5),d0    process CLI-Command-Line
  3797.     beq.s    CCli1
  3798.     clr.l    EntryA0(a5)
  3799.     move.l    d0,a0
  3800.     lea    parm2(a5),a2
  3801.     lea    endofparms(a5),a4    establish end of parms block
  3802. .A    bsr    get_parm        
  3803.     tst.l    d2
  3804.     beq.s    .B
  3805.     move.l    a1,(a2)+
  3806.     cmp.l    a2,a4        get out if more than 25 parms
  3807.     bne.s    .A
  3808.     clr.b    (a0)        make sure last parm ends in 0
  3809. .B    lea    parm2(a5),a1
  3810.     bsr.s    StartOpts
  3811.     bne.s    CCli2a
  3812.     tst.l    d3
  3813.     beq.s    .C
  3814.     bclr    #FLraw,Flags+2(a5)
  3815. .C    tst.l    d1
  3816.     beq.s    CCli1
  3817.     move.l    thistask(a5),a3
  3818.     move.l    pr_CLI(a3),a2
  3819.     add.l    a2,a2
  3820.     add.l    a2,a2
  3821.     bsr    OpenWin
  3822.     tst.l    d0
  3823.     beq.s    CCli2a
  3824.     tst.l    d3
  3825.     beq    CCli1
  3826.     bclr    #FLraw,Flags+2(a5)
  3827.     bra    CCli1
  3828.  
  3829. StartOpts        ;examine startup-options, parms in a1
  3830.     moveq    #0,d1    returns window in d1, script in EntryA0
  3831.     moveq    #0,d2    and start-command in d2
  3832.     moveq    #0,d3    d3>0 if noraw, screen in pubname
  3833. .A    move.l    (a1)+,d0
  3834.     beq.s    Com2Script    exit to Com2Script
  3835.     move.l    d0,a0
  3836.     cmp.b    #"-",(a0)+
  3837.     bne.s    .H
  3838.     move.b    (a0)+,d0
  3839.     or.b    #$20,d0
  3840.     cmp.b    #"s",d0        -s for Script
  3841.     bne.s    .B
  3842.     move.l    a0,EntryA0(a5)
  3843.     bra.s    .A
  3844. .B    cmp.b    #"w",d0        -w for Window
  3845.     bne.s    .C
  3846.     move.l    a0,d1
  3847.     bra.s    .A
  3848. .C    cmp.b    #"c",d0        -c for Command
  3849.     bne.s    .D
  3850.     move.l    a0,d2
  3851.     bra.s    .A
  3852. .D    cmp.b    #"d",d0        -d for detach
  3853.     bne.s    .E
  3854.     clr.l    -4(a1)
  3855.     bsr    initialise_default
  3856.     bsr    newcliz
  3857.     bra.s    .I
  3858. .E    cmp.b    #"r",d0        -r for not Resident
  3859.     beq.s    .A
  3860.     cmp.b    #"n",d0        -n for Noraw
  3861.     bne.s    .F
  3862.     moveq    #1,d3
  3863.     bra.s    .A
  3864. .F    cmp.b    #"e",d0        -e for scrEen
  3865.     bne.s    .H
  3866.     move.l    a0,pubname(a5)
  3867.     bra.s    .A
  3868. .H    cmp.b    #"h",d0        -h for Helpman
  3869.     bne.s    .J
  3870.     move.l    a0,online_help(a5)
  3871.     bra.s    .A
  3872. .J    lea    useit(pc),a1
  3873.     bsr    pr_stringlf
  3874. .I    moveq    #-1,d0
  3875.     rts
  3876.  
  3877. Com2Script        ;Makes a command to script, d2=command
  3878.     move.l    d1,-(sp)    returns d0=0 for OK
  3879.     tst.l    d2        V2.7: uses mult_comm_ptr, cannot fail
  3880.     beq.s    .B
  3881.     lea    null(pc),a0
  3882.     move.l    a0,EntryA0(A5)    no (default) script
  3883.     move.l    d2,a0
  3884.     lea    shelline(a5),a1
  3885.     move.l    a1,mult_comm_ptr(a5)
  3886. .D    move.b    (a0)+,(a1)+    copy command to shelline
  3887.     bne.s    .D
  3888.     move.b    #LF,-1(a1)
  3889.     clr.b    (a1)
  3890. .B    move.l    (sp)+,d1
  3891.     moveq    #0,d0
  3892.     rts
  3893.  
  3894. SetCurrentDir    ;lock in d0
  3895.     move.l    d0,a0
  3896.     add.l    a0,a0
  3897.     add.l    a0,a0
  3898.     move.l    fl_Task(a0),pr_FileSystemTask(a3)
  3899.     move.l    d0,d1
  3900.     jsr    _LVOCurrentDir(a6)
  3901.     move.l    d0,cdir_old(a5)
  3902.     rts
  3903.  
  3904. * Create CLI-Interface-Structure without WB-Message    V2.0 *
  3905.     IFD    DEBUG
  3906. CreateCLI2
  3907.     lea    conname(pc),a0
  3908.     move.l    a0,d1
  3909.     bsr    OpenWin
  3910.     beq.s    .B
  3911.     lea    ramdisk(pc),a0
  3912.     move.l    a0,d1
  3913.     moveq    #-2,d2
  3914.     jsr    _LVOLock(a6)
  3915.     tst.l    d0
  3916.     beq    .B
  3917.     bsr    SetCurrentDir
  3918.     moveq    #0,d0
  3919.     rts
  3920. .B    moveq    #-1,d0
  3921.     rts
  3922.  
  3923. ramdisk    dc.b    "RAM:",0
  3924.     even
  3925.     ENDC
  3926.  
  3927. * Create CLI-Interface-Structure with special message    V2.0
  3928. * ENTRY: a0:wb_msg, a2:CLI_Struct, a3:Process
  3929. *sm_NumArgs:    General Memory Block
  3930. *sm_ToolWindow:    Mode (1=newcli, 2=run, 3=pipe)
  3931. CreateCLI3
  3932.     move.b    sm_ToolWindow(a0),WBflag(a5)    not started from WB
  3933.     move.l    sm_NumArgs(a0),a4    wb_msg in a0
  3934.     move.l    Flags(a4),Flags(a5)
  3935.     move.l    copysize(a4),copysize(a5)
  3936.     move.l    FNCsize(a4),FNCsize(a5)
  3937.     move.l    app_name(a4),app_name(a5)
  3938.     move.l    online_help(a4),online_help(a5)
  3939.     move.l    pubname(a4),pubname(a5)
  3940.     move.l    thistask(a4),a0
  3941.     move.l    pr_CurrentDir(a0),d1
  3942.     move.l    pr_CLI(a0),a0
  3943.     add.l    a0,a0
  3944.     add.l    a0,a0
  3945.     move.l    cli_DefaultStack(a0),cli_DefaultStack(a2)
  3946.     move.l    cli_FailLevel(a0),cli_FailLevel(a2)
  3947.     jsr    _LVODupLock(a6)        COPY CD
  3948.     moveq    #15,d1
  3949.     tst.l    d0
  3950.     beq    cce3
  3951.     bsr    SetCurrentDir
  3952.     move.l    stdout(a4),outhandle(a5)    PROCESS PARMS
  3953.     lea    parm2(a4),a1
  3954.     bsr    StartOpts
  3955.     clr.l    outhandle(a5)
  3956.     tst.l    d0
  3957.     bne    cce2
  3958.     move.l    thistask(a4),a0        OPEN WINDOW
  3959.     move.l    pr_ConsoleTask(a0),pr_ConsoleTask(a3)
  3960.     cmp.b    #2,WBflag(a5)
  3961.     bne.s    .K
  3962.     tst.b    redirect_out(a4)    out-redirected run command ?
  3963.     beq.s    .K
  3964.     tst.l    outhandle(a4)
  3965.     beq.s    .K
  3966.     move.l    outhandle(a4),a0
  3967.     add.l    a0,a0
  3968.     add.l    a0,a0
  3969.     move.l    fh_Type(a0),d0
  3970.     move.l    d0,pr_ConsoleTask(a3)
  3971. .K    lea    conname(pc),a0
  3972.     tst.l    d1
  3973.     bne.s    .H
  3974.     move.l    a0,d1
  3975.     move.l    windowname(a4),d0
  3976.     beq.s    .H
  3977.     move.l    d0,d1
  3978. .H    bsr    OpenWin
  3979.     beq    cce2
  3980.     cmp.b    #2,WBflag(a5)    background tasks are noraw
  3981.     bhs.s    .J
  3982.     btst    #FLraw,Flags+2(a4)    inherit noraw ?
  3983.     beq.s    .J
  3984.     tst.l    d3        force noraw ?
  3985.     beq.s    .B
  3986. .J    bclr    #FLraw,Flags+2(a5)
  3987. .B    move.l    thistask(a4),a0            COPY SEARCH PATHS
  3988.     bsr    CopyPaths
  3989.     lea    prompt_args(a4),a0    COPY PROMPT
  3990.     lea    prompt_args(a5),a1
  3991. .G    move.b    (a0)+,(a1)+
  3992.     bne.s    .G
  3993.     lea    now(a4),a0        COPY HISTORY
  3994.     lea    now(a5),a1
  3995.     move.w    #HISTORY_SIZE+12-1,d0
  3996. .D    move.b    (a0)+,(a1)+
  3997.     dbra    d0,.D
  3998.     moveq    #ctrl_inite-ctrl_init-1,d0    COPY CTRL-CODES
  3999.     lea    ctrl_codes-1(a4),a0
  4000.     lea    ctrl_codes-1(a5),a1
  4001. .E    move.b    (a0)+,(a1)+
  4002.     dbra    d0,.E
  4003.     moveq    #more_inite-more_init-1,d0    COPY MORE-KEYS
  4004.     lea    morekeys(a4),a0
  4005.     lea    morekeys(a5),a1
  4006. .I    move.b    (a0)+,(a1)+
  4007.     dbra    d0,.I
  4008.     lea    FNCignore(a4),a0        COPY FNC-ignore
  4009.     lea    FNCignore(a5),a1
  4010. .F    move.b    (a0)+,(a1)+
  4011.     bne    .F
  4012. ccs1    movem.l    a2-a4,-(sp)    COPY ALL ALIASES
  4013.     lea    first_alias(a4),a2
  4014. .A    move.l    (a2),d0
  4015.     beq.s    .E
  4016.     move.l    d0,-(sp)
  4017.     addq.l    #4,d0        skip link
  4018.     move.l    d0,a2        start to A2
  4019.     move.l    d0,a3
  4020. .C    tst.b    (a3)+        skip name
  4021.     bne.s    .C
  4022. .D    tst.b    (a3)+        skip definition
  4023.     bne.s    .D
  4024.     bsr    copy_new_alias
  4025.     move.l    (sp)+,a2
  4026.     beq.s    .A        check for error
  4027.     moveq    #17,d1
  4028.     bsr    GuruIt
  4029. .E    cmp.b    #2,WBflag(a5)        CREATE REVIEW-BUFFER
  4030.     bhs.s    .F
  4031.     move.l    ReviewSize(a4),d0
  4032.     beq.s    .G
  4033.     bsr    MakeReview
  4034. .G
  4035. .F    movem.l    (sp)+,a2-a4
  4036. ccs2    cmp.b    #2,WBflag(a5)        BACKGROUND PROCESS
  4037.     blo.s    .D
  4038.     moveq    #-1,d0
  4039.     move.l    d0,cli_Background(a2)
  4040.     cmp.b    #3,WBflag(a5)        COPY PIPENAME
  4041.     bne.s    .D
  4042.     lea    pipe_out(a4),a0
  4043.     lea    pipe_in(a5),a1
  4044. .E    move.b    (a0)+,(a1)+
  4045.     bne.s    .E
  4046.     move.l    thistask(a4),PipeTask(a5)
  4047. .D    lea    null(pc),a0    no default script
  4048.     move.l    a0,d0
  4049.     move.l    EntryA0(a5),d1        SCRIPT GIVEN ?
  4050.     beq.s    .A
  4051.     move.l    d1,a0
  4052.     lea    prompt_string(a5),a1    there is enough place
  4053.     move.l    a1,d0
  4054. .B    move.b    (a0)+,(a1)+    Copy Script-Parm
  4055.     bne.s    .B
  4056. .A    move.l    d0,EntryA0(a5)
  4057.     moveq    #RETURN_OK,d0
  4058.     bra.s    cce1
  4059. cce3    bsr    GuruIt
  4060. cce2    moveq    #RETURN_ERROR,d0
  4061. cce1    move.l    d0,-(sp)
  4062.     move.l    4.w,a6
  4063.     move.l    wb_msg(a5),a1
  4064.     move.l    d0,sm_ToolWindow(a1)    return success to calling task
  4065.     jsr    _LVOReplyMsg(a6)
  4066.     clr.l    wb_msg(a5)
  4067.     move.l    dosbase(a5),a6
  4068.     move.l    (sp)+,d0
  4069.     rts
  4070.  
  4071. *************************************************************
  4072. * Open Window for both Input and Output, Name in d1 , a2,a3 *
  4073. *************************************************************
  4074. OpenWin    move.l    dosbase(a5),a6
  4075.     moveq    #0,d0
  4076.     cmp.b    #1,openwin_flag(a5)
  4077.     beq    .C
  4078.     move.b    #1,openwin_flag(a5)
  4079.     move.l    pr_CIS(a3),OldCIS(a5)
  4080.     move.l    pr_COS(a3),OldCOS(a5)
  4081.     clr.l    pr_CIS(a3)        avoid freeing it
  4082.     clr.l    pr_COS(a3)
  4083.     move.l    pr_ConsoleTask(a3),OldCTask(a5)
  4084.     bclr    #FLraw,Flags+2(a5)
  4085.     move.l    d1,a0
  4086.     move.l    a0,windowname(a5)
  4087.     tst.b    (a0)
  4088.     beq    .A            NIL:
  4089.     cmp.w    #36,kickver(a5)
  4090.     blo    .D
  4091.     move.l    pubname(a5),d0
  4092.     beq    .D
  4093.  
  4094.     movem.l    d1-d2/a2,-(sp)    open Public Screen
  4095.     lea    PubTags(pc),a0
  4096.     lea    temp2buf(a5),a1        copy tags-field
  4097.     move.l    a1,a2
  4098. .E    move.l    (a0)+,(a1)+
  4099.     clr.l    (a1)+
  4100.     tst.l    -8(a1)
  4101.     bne.s    .E
  4102.     move.l    d0,a1
  4103.     moveq    #2,d0
  4104.     addq.l    #1,a1
  4105.     tst.b    -1(a1)
  4106.     beq.s    .H
  4107.     subq.l    #1,a1
  4108.     bsr    convert_ASCII_to_num
  4109. .H    move.l    d0,1*4(a2)    Depth
  4110.     move.l    #$8000,d0
  4111.     tst.b    -1(a1)
  4112.     beq.s    .I
  4113.     bsr    convert_ASCII_to_num
  4114. .I    move.l    d0,9*4(a2)    DisplayID
  4115.     moveq    #1,d0
  4116.     tst.b    -1(a1)
  4117.     beq.s    .J
  4118.     bsr    convert_ASCII_to_num
  4119. .J    move.l    d0,11*4(a2)    Overscan
  4120.     lea    ZShellName(pc),a0    fill up tags-field
  4121.     tst.b    -1(a1)
  4122.     beq.s    .G
  4123.     move.l    a1,a0
  4124. .G    move.l    a0,3*4(a2)    Screentitle
  4125.     move.l    a0,7*4(a2)
  4126.     moveq    #2,d0
  4127.     move.l    d0,5*4(a2)    Pubscreen
  4128.     moveq    #12,d0
  4129.     move.l    d0,13*4(a2)    PubSig=ctrl-C
  4130.     lea    PenAray(pc),a0
  4131.     move.l    a0,15*4(a2)    Drawinfo
  4132.     moveq    #1,d0
  4133.     move.l    d0,17*4(a2)    SysFont=System default screenfont
  4134.     move.l    a2,a1
  4135.     sub.l    a0,a0
  4136.     move.l    intuibase(a5),a6
  4137.     jsr    _LVOOpenScreenTagList(a6)    open Screen
  4138.     move.l    d0,pubscreen(a5)
  4139.     beq.s    .F
  4140.     move.l    d0,a0
  4141.     moveq    #0,d0
  4142.     jsr    _LVOPubScreenStatus(a6)    make Pubscreen public
  4143. .F    move.l    dosbase(a5),a6
  4144.     movem.l    (sp)+,d1-d2/a2
  4145.  
  4146. .D    cmp.b    #2,WBflag(a5)
  4147.     bne.s    .L
  4148.     move.l    temp4(a4),d0        use outhandle of RUN command
  4149.     bne.s    .M
  4150. .L    bsr    OpenNewfile        open output-Window
  4151. .M    moveq    #11,d1
  4152.     move.l    d0,pr_COS(a3)
  4153.     beq    .B
  4154.     move.l    d0,d1
  4155.     move.l    d0,cli_StandardOutput(a2)
  4156.     move.l    d0,cli_CurrentOutput(a2)
  4157.     lsl.l    #2,d0
  4158.     move.l    d0,-(sp)
  4159.     jsr    _LVOIsInteractive(a6)
  4160.     moveq    #12,d1
  4161.     move.l    (sp)+,a0
  4162.     tst.l    d0
  4163.     bne.s    .K
  4164.     cmp.b    #2,WBflag(a5)    NIL: output on RUN command ?
  4165.     beq.s    .A
  4166.     bra.s    .B
  4167. .K    move.l    fh_Type(a0),d0
  4168.     move.l    d0,pr_ConsoleTask(a3)
  4169.     bset    #FLraw,Flags+2(a5)
  4170.     lea    star(pc),a0
  4171.     move.l    a0,d1
  4172.     bsr    OpenOldfile        open input-window
  4173.     moveq    #13,d1
  4174.     move.l    d0,pr_CIS(a3)
  4175.     beq    .B
  4176.     move.l    d0,cli_StandardInput(a2)
  4177.     move.l    d0,cli_CurrentInput(a2)
  4178. .A    bsr    GetWindowPtr
  4179.     clr.l    raw_mode(a5)
  4180.     moveq    #-1,d0
  4181.     rts            d0<>0 if OK
  4182. .C    moveq    #10,d1
  4183. .B    bra    GuruIt        d0=0 on error
  4184.  
  4185. PubTags    dc.l    $80000000+37    Depth=2/1
  4186.     dc.l    $80000000+40    Title=*ZShell/3
  4187.     dc.l    $80000000+45    Type=Publicscreen/5
  4188.     dc.l    $80000000+47    PubName=*ZShell/7
  4189.     dc.l    $80000000+50    DisplayID=Hires/9
  4190.     dc.l    $80000000+52    Overscan=1/11
  4191.     dc.l    $80000000+48    PubSig=12/13
  4192.     dc.l    $80000000+58    Pens=*PenArray/15
  4193.     dc.l    $80000000+44    SysFont=1/17
  4194.     dc.l    0
  4195. PenAray    dc.w    0,-1
  4196.  
  4197. *******************************
  4198. CloseWin
  4199.     move.l    thistask(a5),a3
  4200.     tst.b    openwin_flag(a5)
  4201.     beq.s    .A
  4202.     move.l    pr_CIS(a3),d1
  4203.     beq.s    .C
  4204.     jsr    _LVOClose(a6)    close input-window
  4205. .C    move.l    pr_COS(a3),d1
  4206.     beq.s    .D
  4207.     jsr    _LVOClose(a6)    close output-window
  4208. .D    move.l    OldCIS(a5),d0
  4209.     move.l    d0,pr_CIS(a3)
  4210.     move.l    OldCOS(a5),d1
  4211.     move.l    d1,pr_COS(a3)
  4212.     move.l    OldCTask(a5),pr_ConsoleTask(a3)
  4213.     tst.l    pr_CLI(a3)
  4214.     beq.s    .G
  4215.     move.l    pr_CLI(a3),a2
  4216.     add.l    a2,a2
  4217.     add.l    a2,a2
  4218.     move.l    d0,cli_StandardInput(a2)
  4219.     move.l    d0,cli_CurrentInput(a2)
  4220.     move.l    d1,cli_StandardOutput(a2)
  4221.     move.l    d1,cli_CurrentOutput(a2)
  4222. .G    move.l    pubscreen(a5),d0
  4223.     beq.s    .A
  4224.     move.l    d0,a0
  4225.     move.l    intuibase(a5),a6
  4226.     jsr    _LVOCloseScreen(a6)    close Public Screen
  4227.     tst.l    d0
  4228.     bne.s    .A
  4229.     move.l    4.w,a6
  4230.     moveq    #0,d0
  4231.     bset    #SIGBREAKB_CTRL_C,d0
  4232.     jsr    _LVOWait(a6)
  4233.     bra.s    .G
  4234. .A    move.l    dosbase(a5),a6
  4235.     rts
  4236.  
  4237. **********************************************
  4238. * Remove CLI-Interface-Structure    V2.0 *
  4239. **********************************************
  4240. RemoveCLI
  4241.     move.l    thistask(a5),a3
  4242.     IFD    KILL
  4243.     cmp.w    #36,kickver(a5)
  4244.     blo.s    .G
  4245.     clr.l    pr_ExitCode(a3)
  4246. .G    ENDC
  4247.     move.l    oldwindowptr(a5),pr_WindowPtr(a3)
  4248.     move.l    old_homedir(a5),d0
  4249.     beq.s    .B
  4250.     move.l    d0,pr_HomeDir(a3)
  4251. .B
  4252.     bsr    clkoff
  4253.     bsr    CloseWin
  4254.     move.l    diskobj(a5),d0
  4255.     beq.s    .F
  4256.     move.l    d0,a0
  4257.     move.l    iconbase(a5),a6
  4258.     jsr    _LVOFreeDiskObject(a6)
  4259. .F    move.l    4.w,a6
  4260.     move.l    iconbase(a5),d0
  4261.     beq.s    .A
  4262.     move.l    d0,a1
  4263.     jsr    _LVOCloseLibrary(a6)
  4264. .A    move.l    wbbase(a5),d0
  4265.     beq.s    .C
  4266.     move.l    d0,a1
  4267.     jsr    _LVOCloseLibrary(a6)
  4268. .C    move.l    utilbase(a5),d0
  4269.     beq.s    .D
  4270.     move.l    d0,a1
  4271.     jsr    _LVOCloseLibrary(a6)
  4272. .D    move.l    dosbase(a5),a6
  4273.     move.l    pr_CLI(a3),d0
  4274.     beq    remend
  4275.     lsl.l    #2,d0
  4276.     move.l    d0,a2
  4277.     moveq    #10,d0
  4278.     move.l    d0,cli_FailLevel(a2)
  4279.     move.l    old_setname(a5),d0
  4280.     beq.s    remcli
  4281.     move.l    d0,cli_SetName(a2)
  4282.     lsl.l    #2,d0
  4283.     move.l    d0,a1
  4284.     lea    CD_string(a5),a0
  4285. .E    move.b    (a0)+,(a1)+    copy current dir name
  4286.     bne.s    .E
  4287.     move.l    old_prompt(a5),cli_Prompt(a2)
  4288.  
  4289. remcli    tst.b    CLIflag(a5)
  4290.     beq.s    remend
  4291.     clr.l    pr_CLI(a3)    clear CLI-Pointer
  4292.     move.l    pr_TaskNum(a3),d0
  4293.     beq.s    .E
  4294.     lsl.l    #2,d0
  4295.     move.l    dl_Root(a6),a0
  4296.     move.l    (a0),a0
  4297.     add.l    a0,a0
  4298.     add.l    a0,a0
  4299.     add.l    d0,a0
  4300.     clr.l    (a0)        free task-number
  4301.     clr.l    pr_TaskNum(a3)
  4302. .E    lea    cli_CommandDir(a2),a4
  4303.     bsr    DeletePaths    free search paths
  4304.     move.l    cdir_old(a5),d1
  4305.     jsr    _LVOCurrentDir(a6)
  4306.     move.l    d0,d1
  4307.     beq.s    .B
  4308.     jsr    _LVOUnLock(a6)    free current dir
  4309. .B    move.l    filesys_old(a5),pr_FileSystemTask(a3)
  4310.     clr.l    pr_Result2(a3)
  4311.     move.l    #64+$28+$50,d0
  4312.     move.l    a2,a1
  4313.     bsr    givemem        free memory of CLI
  4314. remend    move.l    dosbase(a5),a6
  4315.     rts
  4316.  
  4317. **************************************************************
  4318. GuruIt    ;get errornumber in d1 and display a recoverable alert
  4319.     movem.l    d0-d1/a0-a2/a6,-(sp)
  4320.     lea    tempbuf(a5),a0
  4321.     move.l    a0,a1
  4322.     clr.b    (a1)+
  4323.     move.b    #250,(a1)+
  4324.     move.b    #15,(a1)+
  4325.     lea    ZShellName(pc),a2
  4326. .A    move.b    (a2)+,(a1)+
  4327.     bne.s    .A
  4328.     move.b    #" ",-1(a1)
  4329.     move.l    d1,d0
  4330.     bsr    qpr10
  4331.     clr.b    (a1)+
  4332.     clr.b    (a1)+
  4333.     move.l    intuibase(a5),a6
  4334.     moveq    #0,d0
  4335.     moveq    #35,d1
  4336.     jsr    _LVODisplayAlert(a6)
  4337.     movem.l    (sp)+,d0-d1/a0-a2/a6
  4338.     tst.l    d0
  4339.     rts
  4340.  
  4341. *CHECK WHETHER THERE IS ENOUGH STACK FREE    V2.0 *
  4342. ;d0=requested stacksize
  4343. stacktest movem.l    d0-d1/a0-a1,-(sp)
  4344.     move.l    topstack(a5),a0
  4345.     sub.l    sp,a0
  4346.     move.l    a0,d1
  4347.     add.l    d0,d1
  4348.     add.l    #1600,d1    ;allow some bytes for DOS
  4349.     cmp.l    stacksize(a5),d1
  4350.     blo.s    .A
  4351.     lea    stack_tx(pc),a0
  4352.     bsr    PrintError
  4353.     moveq    #-1,d0
  4354.     bra.s    .B
  4355. .A    moveq    #0,d0
  4356. .B    movem.l    (sp)+,d0-d1/a0-a1
  4357.     rts
  4358.  
  4359. bad_number_error
  4360.     moveq    #115,d0
  4361.     bra.s    pr_galactic
  4362.  
  4363. too_less_args
  4364.     moveq    #116,d0
  4365.     bra.s    pr_galactic
  4366.  
  4367. *SendPacket-Error-Tester
  4368. PKTerr    tst.l    sp_res1(a5)
  4369.     bne    .A
  4370.     move.l    sp_res2(a5),d0
  4371.     bra.s    pr_galactic
  4372. .A    rts
  4373. *DOSERRor but Unlock first using D7 as the lock
  4374. DOSerrUL    move.l d7,d1        ;Assume D7=lock
  4375.     beq.s    DOSerr
  4376.     move.l    thistask(a5),a2
  4377.     move.l    pr_Result2(a2),d2
  4378.     jsr    _LVOUnLock(a6)
  4379.     move.l    d2,pr_Result2(a2)
  4380. *DOSERRor handler
  4381. DOSerr    jsr    _LVOIoErr(a6)
  4382.     cmp.l    #232,d0
  4383.     bne.s    pr_galactic
  4384.     moveq    #0,d0
  4385.     rts            ;Return if ERROR_NO_MORE_ENTRIES
  4386.  
  4387. pr_galactic
  4388.     bsr.s    pr_DOSerr    ;entry for dospacket
  4389. galactic
  4390.     move.l    errorstack(a5),sp    ;restore stack
  4391.     moveq    #RETURN_BAD,d0
  4392.     bra    chkfail        ;reenter shell loop
  4393.  
  4394. maybeDOSerr    ;checks if d0=0, then prints DOSerr
  4395.     move.l    d0,-(sp)
  4396.     bne.s    .A
  4397.     jsr    _LVOIoErr(a6)
  4398.     bsr    pr_DOSerr        error occured
  4399. .A    move.l    (sp)+,d0
  4400.     rts
  4401.  
  4402. * ENTRY D0=dos error number
  4403. pr_DOSerr
  4404.     clr.b    noreview_flag(a5)
  4405.     move.l    a2,-(sp)
  4406.     move.l    d0,-(sp)
  4407.     bsr    pr_DOSerr1
  4408.     bsr    GetMessage
  4409.     bsr    pr_DOSerr2
  4410.     tst.l    d0
  4411.     bne.s    .A
  4412.     move.l    #-155,d0
  4413.     bsr    GetMessage
  4414.     move.l    sp,a1
  4415.     bsr    new_print
  4416. .A    lea    lf(pc),a1
  4417.     bsr    pr_error
  4418.     addq.l    #4,sp
  4419.     move.l    (sp)+,a2
  4420.     moveq    #RETURN_ERROR,d0
  4421.     rts
  4422.  
  4423. pr_DOSerr1
  4424.     lea    NewPrintBuffer(a5),a2
  4425.     lea    farb2(pc),a1
  4426.     bsr    addstring
  4427.     move.l    parm1(a5),a1
  4428.     bsr    addstring
  4429.     move.b    #":",(a2)+
  4430.     move.b    #" ",(a2)+
  4431.     rts
  4432.  
  4433. pr_DOSerr2
  4434.     move.l    a0,a1
  4435.     bsr    addstring
  4436.     lea    farb1(pc),a1
  4437.     bsr    addstring
  4438.     lea    NewPrintBuffer(a5),a1
  4439.     bsr    pr_error
  4440.     rts
  4441.  
  4442. PrintError    ;string to print in a0
  4443.     move.l    a2,-(sp)
  4444.     bsr    pr_DOSerr1
  4445.     bsr    pr_DOSerr2
  4446.     lea    lf(pc),a1
  4447.     bsr    pr_error
  4448.     move.l    (sp)+,a2
  4449.     moveq    #RETURN_ERROR,d0
  4450.     rts
  4451.  
  4452. GetMessage
  4453.     cmp.w    #36,kickver(a5)
  4454.     blo.s    .E
  4455.     movem.l    d2-d4,-(sp)    OS2.0+ stuff
  4456.     move.l    d0,d1
  4457.     lea    null(pc),a0
  4458.     move.l    a0,d2
  4459.     lea    gather(a5),a0
  4460.     clr.b    2(a0)
  4461.     move.l    a0,d3
  4462.     moveq    #80,d4
  4463.     jsr    _LVOFault(a6)
  4464.     movem.l    (sp)+,d2-d4
  4465.     lea    gather+2(a5),a0
  4466.     rts
  4467. .E    lea    doserror_text(pc),a0    OS1.3- stuff
  4468.     bra.s    .C
  4469. .B    tst.b    (a0)+
  4470.     bne.s    .B
  4471. .C    move.b    (a0)+,d1
  4472.     beq.s    .A
  4473.     cmp.b    d1,d0
  4474.     bne.s    .B
  4475.     rts
  4476. .A    moveq    #0,d0
  4477.     rts
  4478.  
  4479. * PRINT DECIMAL print D0 as decimal
  4480. print10    movem.l    d0/a0-a1,-(sp)
  4481.     move.l    d0,-(sp)
  4482.     move.l    sp,a1
  4483.     lea    format(pc),a0
  4484.     bsr    new_print
  4485.     addq.l    #4,sp
  4486.     movem.l    (sp)+,d0/a0-a1
  4487.     rts
  4488.  
  4489. * PRINT HEXADECIMAL address in D0
  4490. printADR movem.l    d0/a0-a1,-(sp)
  4491.     move.l    d0,-(sp)
  4492.     move.l    sp,a1
  4493.     lea    formatADR(pc),a0
  4494.     bsr    new_print
  4495.     addq.l    #4,sp
  4496.     movem.l    (sp)+,d0/a0-a1
  4497.     rts
  4498.  
  4499. pr_prompt
  4500.     lea    prompt_string(a5),a1
  4501. pr_error
  4502.     movem.l    d0-d3/a0-a1,-(sp)
  4503.     move.l    stdout(a5),d1
  4504.     bra.s    pr_str1
  4505.  
  4506. pr_space lea    space(pc),a1
  4507.     bra.s    pr_string
  4508. pr_tab    lea tab(pc),a1
  4509.     bra.s pr_string
  4510. pr_lf    lea lf(pc),a1
  4511.  
  4512. *PRINT STRING at a1    ;saves some of the important low registers
  4513. pr_string
  4514.     movem.l    d0-d3/a0-a1,-(sp)    print String in a1
  4515.     move.l    outhandle(a5),d1
  4516. pr_str1    beq.s    .B
  4517.     move.l    a1,d2
  4518.     moveq    #-1,d3
  4519. .A    addq.l    #1,d3
  4520.     tst.b    (a1)+
  4521.     bne.s    .A
  4522.     jsr    _LVOWrite(a6)
  4523. .B    movem.l    (sp)+,d0-d3/a0-a1
  4524.     rts
  4525.  
  4526. OpenOldfile
  4527.     move.l    #MODE_OLDFILE,d2
  4528.     jmp    _LVOOpen(a6)
  4529.  
  4530. OpenNewfile
  4531.     move.l    #MODE_NEWFILE,d2
  4532.     jmp    _LVOOpen(a6)
  4533.  
  4534. OpenReadWrite
  4535.     move.l    #MODE_READWRITE,d2
  4536.     jmp    _LVOOpen(a6)
  4537.  
  4538. * Simple Memory Pool Manager, no single deallocations possible V2.9
  4539. pud_link = 0    ;APTR    Link to next puddle
  4540. pud_free = 4    ;APTR    Points to start of free space in current puddle
  4541. pud_size = 8    ;LONG    Size of current puddle
  4542. pud_resv = 12    ;LONG    Reserved
  4543. pud_data = 16    ;    puddle data
  4544. ;POOLSIZE=size of standard puddles, but size can vary
  4545. * Create memory pool, no entry, exit: d0=poolheader d1=first free pos
  4546. CreatePool
  4547.     move.l    #POOLSIZE,d0
  4548.     bsr    iwantcleanmem    allocate first puddle
  4549.     move.l    d0,d1
  4550.     beq.s    .A
  4551.     move.l    d0,a0
  4552.     addq.l    #8,d1
  4553.     addq.l    #8,d1
  4554.     move.l    d1,pud_free(a0)
  4555.     move.l    #POOLSIZE,pud_size(a0)
  4556. .A    rts
  4557.  
  4558. * Delete whole memory pool, entry: a0=poolheader (may be 0), no exit
  4559. DeletePool
  4560.     move.l    a0,d0
  4561.     beq.s    .C
  4562. .A    move.l    (a0),-(sp)
  4563.     move.l    a0,a1
  4564.     move.l    pud_size(a0),d0
  4565.     bsr    givemem        free all puddles
  4566.     move.l    (sp)+,d0
  4567.     move.l    d0,a0
  4568.     bne.s    .A
  4569. .C    rts
  4570.  
  4571. * Allocate memory in pool, entry: a0=poolheader d0=size, exit: d0=addr
  4572. AllocPooled
  4573.     move.l    d2,-(sp)
  4574.     addq.l    #1,d0
  4575.     bclr    #0,d0        word-align
  4576.     cmp.l    #(POOLSIZE-pud_data)/2,d0    is it too big for pool ?
  4577.     bls.s    .A
  4578.     addq.l    #8,d0
  4579.     addq.l    #8,d0
  4580.     move.l    d0,d2
  4581.     bsr    iwantcleanmem    allocate separate memory for it
  4582.     beq.s    .F
  4583.     move.l    d0,a1
  4584.     move.l    d2,pud_size(a1)    size is different from POOLSIZE !
  4585.     add.l    a1,d2
  4586.     move.l    d2,pud_free(a1)    declare it as full
  4587.     move.l    a0,d1
  4588. .C    move.l    d1,a0
  4589.     move.l    (a0),d1
  4590.     bne.s    .C        look for end of puddles list
  4591.     move.l    a1,pud_link(a0)    connect
  4592.     addq.l    #8,d0
  4593.     addq.l    #8,d0
  4594.     bra.s    .F
  4595.  
  4596. .A    move.l    a0,d2
  4597. .B    move.l    d2,a0
  4598.     move.l    d0,d1
  4599.     move.l    pud_free(a0),a1
  4600.     add.l    a1,d1
  4601.     sub.l    a0,d1
  4602.     cmp.l    pud_size(a0),d1    check if it fits into puddle
  4603.     bls.s    .D
  4604.     move.l    (a0),d2
  4605.     bne.s    .B        look for end of puddles list
  4606.  
  4607.     move.l    d0,d2
  4608.     move.l    a0,-(sp)
  4609.     bsr    CreatePool    allocate new puddle
  4610.     move.l    (sp)+,a0
  4611.     beq.s    .F
  4612.     move.l    d0,(a0)        connect
  4613.     move.l    d0,a0
  4614.     move.l    d2,d0
  4615.     move.l    d1,a1
  4616. .D    add.l    d0,pud_free(a0)
  4617.     move.l    a1,d0
  4618. .F    move.l    (sp)+,d2
  4619.     tst.l    d0
  4620.     rts
  4621.  
  4622. * Allocate memory in pool and copy string in there
  4623. * Entry: a0=poolheader d0=string, exit: d0=string in pool
  4624. StringPooled
  4625.     move.l    d0,-(sp)
  4626.     move.l    d0,a1
  4627. .A    tst.b    (a1)+
  4628.     bne.s    .A
  4629.     sub.l    d0,a1
  4630.     move.l    a1,d0
  4631.     bsr    AllocPooled
  4632.     move.l    (sp)+,a1
  4633.     beq    resi_no_mem
  4634.     move.l    d0,a0
  4635. .C    move.b    (a1)+,(a0)+
  4636.     bne.s    .C
  4637.     rts
  4638.  
  4639. *ALLOCATE MEMORY D0=size D1=type
  4640. iwantcleanmem    
  4641.     movem.l d1/a0-a1,-(sp)
  4642.     move.l    #MEMF_CLEAR+1,d1
  4643.     bra.s    iwmem
  4644. iwantmem    
  4645.     movem.l d1/a0-a1,-(sp)
  4646.     moveq    #1,d1
  4647. iwmem    move.l    4.w,a6
  4648.     jsr    _LVOAllocMem(a6)
  4649.     move.l    dosbase(a5),a6
  4650.     tst.l    d0
  4651.     bne.s    .A
  4652.     move.l    thistask(a5),a0
  4653.     moveq    #103,d1
  4654.     move.l    d1,pr_Result2(a0)
  4655. .A    movem.l (sp)+,d1/a0-a1
  4656.     tst.l    d0
  4657.     rts
  4658.  
  4659. *FREEMEM A1=ptr to mem block D0=size
  4660. givemem    move.l    4.w,a6
  4661.     jsr    _LVOFreeMem(a6)
  4662.     move.l    dosbase(a5),a6
  4663.     rts
  4664.  
  4665.  
  4666. * ALTER WINDOW PTR FOR THIS PROCESS. USE TO DISABLE REQUESTERS POPPING UP.
  4667. * ENTRY D1=0 (NORMAL)  D1=-1 (SUBNORMAL, no requesters).
  4668. RequestersOff
  4669.     movem.l    d1/a0,-(sp)
  4670.     moveq    #-1,d1
  4671.     bra.s    changeWindowPtr
  4672.  
  4673. RequestersOn
  4674.     movem.l    d1/a0,-(sp)
  4675.     move.l    windowptr(a5),d1
  4676.  
  4677. changeWindowPtr    
  4678.     move.l    thistask(a5),a0
  4679.     move.l    d1,pr_WindowPtr(a0)
  4680.     movem.l    (sp)+,d1/a0
  4681.     rts
  4682.  
  4683. pr_show_cursor
  4684.     btst    #FLhide,Flags+2(a5)
  4685.     beq.s    .A
  4686.     tst.b    redirect_out(a5)
  4687.     bne.s    .A
  4688.     tst.b    cursor_mode(a5)
  4689.     beq.s    .A
  4690.     addq.b    #1,noreview_flag(a5)
  4691.     lea    show_cursor(pc),a1
  4692.     bsr    pr_string
  4693.     subq.b    #1,noreview_flag(a5)
  4694.     clr.b    cursor_mode(a5)
  4695. .A    rts
  4696.  
  4697. pr_hide_cursor
  4698.     btst    #FLhide,Flags+2(a5)
  4699.     beq.s    .A
  4700.     tst.b    redirect_out(a5)
  4701.     bne.s    .A
  4702.     tst.b    cursor_mode(a5)
  4703.     bne.s    .A
  4704.     addq.b    #1,noreview_flag(a5)
  4705.     lea    hide_cursor(pc),a1
  4706.     bsr    pr_string
  4707.     subq.b    #1,noreview_flag(a5)
  4708.     move.b    #1,cursor_mode(a5)
  4709. .A    rts
  4710.  
  4711. raw_on    movem.l    d0/a1,-(sp)    switch console to raw mode
  4712.     moveq    #-1,d0
  4713.     bra.s    raw_switch
  4714.  
  4715. raw_off    movem.l    d0/a1,-(sp)    switch console to normal mode
  4716.     moveq    #0,d0
  4717. ;    bra.s    raw_switch
  4718.  
  4719. *WINDOW TYPE CHANGER    
  4720. raw_switch
  4721.     cmp.l    raw_mode(a5),d0
  4722.     beq.s    .A
  4723.     move.l    d0,raw_mode(a5)
  4724.     move.l    thistask(a5),a1
  4725.     move.l    pr_ConsoleTask(a1),packettask(a5)
  4726.     bsr    clearArgs
  4727.     move.l    #ACTION_SCREEN_MODE,packettype(a5)
  4728.     move.l    d0,myArg1(a5)
  4729.     bsr    sendpacket
  4730. .A    movem.l    (sp)+,d0/a1
  4731.     rts
  4732.  
  4733. ** ENTRY Uses myArg1-myArg7, and packettask, packettype
  4734. sendpacket    tst.l    packettask(a5)
  4735.     beq.s    .A
  4736.     movem.l    d0-d1/a0-a2,-(sp)    V2.0 (new written)
  4737.     bsr    sendpacket2
  4738.     move.l    a2,a0
  4739.     jsr    _LVOWaitPort(a6)
  4740.     move.l    a2,a0
  4741.     jsr    _LVOGetMsg(a6)
  4742.     move.l    dosbase(a5),a6
  4743.     movem.l    (sp)+,d0-d1/a0-a2
  4744.     tst.l    sp_res1(a5)
  4745. .A    rts
  4746.  
  4747. sendpacket2    ;used by sendpacket and get_one_char
  4748.     move.l    4.w,a6
  4749.     move.b    #5,LN_TYPE+sp_node(a5)    message
  4750.     move.l    thistask(a5),a2
  4751.     lea    pr_MsgPort(a2),a2    Process-MsgPort !
  4752.     move.l    a2,sp_reply(a5)        Replyport
  4753.     move.l    a2,sp_port(a5)
  4754.     move.w    #dp_SIZEOF+4,sp_length(a5)
  4755.     lea    sp_link(a5),a0
  4756. ;    move.l    a0,sp_ptr(a5)
  4757.     move.l    a0,LN_NAME+sp_node(a5)    points to link
  4758.     lea    sp_node(a5),a1
  4759.     move.l    a1,sp_link(a5)        linked to itself
  4760.     move.l    packettask(a5),a0
  4761.     jsr    _LVOPutMsg(a6)
  4762.     rts
  4763.  
  4764. clearArgs movem.l    d0/a0,-(sp)
  4765.     lea    sp_node(a5),a0
  4766.     moveq    #16,d0    ;68bytes
  4767. .A    clr.l    (a0)+
  4768.     dbra    d0,.A
  4769.     movem.l    (sp)+,d0/a0
  4770.     rts
  4771.  
  4772. *Match the string pointed to by A0 to one in a table pted to by a1
  4773. *The number of the matched string is linked to an offset table pted to by
  4774. *A2.  return with 
  4775. *D2 holding offset from 'cmdstart' so a jsr 0(a0,d2.w) can be done
  4776. *Entry    A1 pts to Command text table  A2 pts to command offset table
  4777. matchcmd
  4778.     lea    comtext(pc),a1
  4779.     lea    comoffs(pc),a2
  4780.     moveq    #0,d1    command count
  4781.     move.l    a0,a3    save command
  4782.     moveq    #0,d3
  4783. mat1    move.b    (a1)+,d3    save number of args
  4784. mat2    move.b    (a0)+,d0
  4785.     bset    #5,d0
  4786.     cmp.b    dotchar(a5),d0    check "."
  4787.     bne.s    .A
  4788.     tst.b    (a0)
  4789.     beq.s    foundit    shortcut
  4790. .A    move.b    (a1),d2
  4791.     bset    #5,d2
  4792.     cmp.b    d2,d0
  4793.     bne.s    nextcom    if any character wrong then check next
  4794.     addq.l    #1,a1
  4795.     tst.b    -1(a0)    check whether 0 was last compared
  4796.     beq.s    foundit    if it was then success
  4797.     bra.s    mat2
  4798. nextcom    tst.b    (a1)+
  4799.     bne.s    nextcom
  4800.     addq.l    #2,d1    each offset is a word
  4801.     move.l    a3,a0
  4802.     tst.b    1(a1)    put 0,0 at end of com table
  4803.     bne.s    mat1
  4804.     moveq    #0,d2    D2 = 0 if command not found
  4805.     rts
  4806. foundit    tst.b    d3
  4807.     bmi.s    .A
  4808.     lsl.l    #2,d3
  4809.     lea    parm2(a5),a0
  4810.     tst.l    0(a0,d3.l)
  4811.     beq.s    .A
  4812.     moveq    #118,d0        too many args error
  4813.     bra    pr_galactic
  4814. .A    move.w    0(a2,d1.l),d2    get offset
  4815.     rts
  4816.  
  4817. *****************************************
  4818. *    Start of internal commands    *
  4819. *****************************************
  4820. cmdstart
  4821.  
  4822. FreeStuff    ;deallocates stuff alllocated by commands
  4823.     bsr    deallocate_aliases
  4824.     bra    reviewend
  4825.  
  4826.  
  4827. *************************
  4828. *    RUN        *    V2.2
  4829. *************************
  4830. runz    clr.l    temp4(a5)
  4831.     tst.b    redirect_out(a5)
  4832.     beq.s    .B
  4833.     tst.l    MPipePtr(a5)
  4834.     bne.s    .B
  4835.     tst.b    pipe_out(a5)
  4836.     bne.s    .B
  4837.     move.l    thistask(a5),a0
  4838.     move.l    pr_COS(a0),temp4(a5)
  4839.     move.l    stdout(a5),pr_COS(a0)    restore old stdout
  4840.     move.l    stdout(a5),outhandle(a5)    
  4841. .B    clr.b    redirect_out(a5)
  4842.     clr.l    parm4(a5)
  4843.     lea    tempbuf(a5),a0
  4844.     move.l    a0,parm2(a5)
  4845.     move.l    #"-w*"<<8,(a0)+
  4846.     move.l    a0,parm3(a5)
  4847.     move.w    #'-c',(a0)+
  4848.     lea    CLIbuf(a5),a1
  4849. .A    move.b    (a1)+,(a0)+    copy CLIbuf
  4850.     bne.s    .A
  4851.     moveq    #2,d7
  4852.     bra.s    create_new_cli
  4853.  
  4854. *************************
  4855. *    NewCLI        *    V2.0
  4856. *************************
  4857. newcliz    moveq    #1,d7
  4858. create_new_cli        ;ENTRY: d7=Mode
  4859.     tst.b    noresi_flag(a5)
  4860.     bne    .B
  4861.     lea    ZShellName(pc),a0
  4862.     move.l    a0,d1        process-name
  4863.     move.l    thistask(a5),a0
  4864.     moveq    #0,d2        priority
  4865.     move.b    LN_PRI(a0),d2
  4866.     lea    start-4(pc),a0
  4867.     move.l    a0,d3        
  4868.     lsr.l    #2,d3        seglist
  4869.     move.l    #4000,d4    stacksize
  4870.     jsr    _LVOCreateProc(a6)
  4871.     tst.l    d0
  4872.     beq.s    .B
  4873.     move.l    d0,a4        a4:new process
  4874.     moveq    #$24,d0
  4875.     bsr    iwantcleanmem    memory for Message
  4876.     beq.s    .B
  4877.     move.l    d0,a1        a1,a3:message
  4878.     move.l    a1,a3
  4879.     move.b    #5,LN_TYPE(a1)
  4880.     move.l    thistask(a5),a0
  4881.     lea    pr_MsgPort(a0),a2    a2:msgport of this task
  4882.     move.l    a2,mn_ReplyPort(a1)
  4883.     move.w    #$24,mn_Length(a1)
  4884.     move.l    a5,sm_NumArgs(a1)
  4885.     move.b    d7,sm_ToolWindow(a1)
  4886.     move.l    a4,a0
  4887.     move.l    4.w,a6
  4888.     jsr    _LVOPutMsg(a6)
  4889. .A    move.l    a2,a0
  4890.     jsr    _LVOWaitPort(a6)
  4891.     move.l    a2,a0
  4892.     jsr    _LVOGetMsg(a6)
  4893.     cmp.l    a3,d0
  4894.     bne    .A
  4895.     move.l    sm_ToolWindow(a3),-(sp)    return value
  4896. ;    move.l    dosbase(a5),a6
  4897.     move.l    d0,a1
  4898.     moveq    #$24,d0
  4899.     bsr    givemem
  4900.     move.l    (sp)+,d0
  4901.     rts
  4902. .B    moveq    #RETURN_ERROR,d0
  4903.     rts
  4904.  
  4905. *************************
  4906. *    RENAME        *
  4907. *************************
  4908. renamez    move.l    parm3(a5),d2
  4909.     beq    too_less_args
  4910.     move.l    parm2(a5),d1
  4911.     jsr    _LVORename(a6)
  4912.     tst.l    d0
  4913.     beq    DOSerr
  4914.     moveq    #RETURN_OK,d0
  4915.     rts
  4916.  
  4917. *************************
  4918. *    MAKEDIR        *
  4919. *************************
  4920. makedirz    lea    parm2(a5),a4
  4921. .A    move.l    (a4)+,d1
  4922.     beq.s    .B
  4923.     bsr.s    mkdir
  4924.     bra.s    .A
  4925. .B    moveq    #RETURN_OK,d0
  4926.     rts
  4927.     
  4928. *MAKEDIR D1-> directory name
  4929. mkdir    jsr    _LVOCreateDir(a6)
  4930.     tst.l    d0
  4931.     beq    DOSerr
  4932.     move.l    d0,d1
  4933.     jsr    _LVOUnLock(a6)
  4934. *    moveq    #0,d0
  4935.     rts
  4936.  
  4937. *************************
  4938. *    PROMPT        *
  4939. *************************
  4940. promptz    move.l    parm2(a5),d0
  4941.     beq.s    .B
  4942.     bsr    parse_echo
  4943.     move.l    parm2(a5),a0
  4944.     lea    prompt_args(a5),a2
  4945.     lea    1(a2),a1
  4946.     moveq    #-1,d0
  4947. .A    addq.b    #1,d0
  4948.     move.b    (a0)+,(a1)+
  4949.     bne.s    .A
  4950. .C    move.b    d0,(a2)
  4951.     MOVEQ    #RETURN_OK,D0
  4952.     rts
  4953. .B    lea    prompt_args+1(a5),a1
  4954.     bsr    pr_stringlf
  4955.     moveq    #RETURN_OK,d0
  4956.     rts
  4957.     
  4958. **************    
  4959. compose_prompt
  4960.     lea    prompt_string(a5),a1
  4961.     move.l    a1,prompt_cr(a5)
  4962.     lea    farb3(pc),a0
  4963. .C    move.b    (a0)+,(a1)+    copy highlight colour
  4964.     bne.s    .C
  4965.     subq.l    #1,a1
  4966.     lea    prompt_args+1(a5),a0
  4967. cpro3    move.b    (a0)+,d0
  4968.     beq    composer3
  4969.     cmp.b    #$5c,d0 ;\
  4970.     bne.s    .A
  4971.     move.b    (a0)+,d0
  4972.     bra    composer2
  4973. .A    cmp.b    #'%',d0
  4974.     bne    composer2
  4975.     move.b    (a0)+,d0
  4976.     bset    #5,d0
  4977.     cmp.b    #'p',d0        check if %p
  4978.     bne.s    try_halfcd
  4979.     lea    CD_string+1(a5),a2
  4980. .B    move.b    (a2)+,(a1)+    copy cd_string to prompt_string
  4981.     bne.s    .B
  4982.     lea    -1(a1),a1
  4983.     bra    cpro3
  4984. try_halfcd
  4985.     cmp.b    #'s',d0        check if %s
  4986.     bne.s    try_line_num
  4987.     lea    CD_string+1(a5),a2
  4988.     move.l    a2,d1
  4989. .A    tst.b    (a2)+
  4990.     bne.s    .A
  4991.     subq.l    #2,a2
  4992.     bra.s    .D
  4993. .C    move.b    -(a2),d0
  4994. .D    cmp.l    a2,d1
  4995.     bhi.s    .E
  4996.     cmp.b    #"/",d0
  4997.     beq.s    .E
  4998.     cmp.b    #":",d0
  4999.     bne.s    .C
  5000. .E    addq.l    #1,a2
  5001. .B    move.b    (a2)+,(a1)+    copy cd_string to prompt_string
  5002.     bne.s    .B
  5003.     lea    -1(a1),a1
  5004.     bra    cpro3
  5005. try_line_num
  5006.     cmp.b    #'l',d0        check if %l
  5007.     bne.s    try_oldcmd
  5008.     move.l    count_line(a5),d0
  5009.     moveq    #0,d1
  5010.     move.l    a1,a2
  5011.     bsr    qdecpr        insert current line number
  5012.     move.l    a2,a1
  5013.     bra    cpro3
  5014. try_oldcmd
  5015.     cmp.b    #'c',d0        check if %c
  5016.     bne.s    try_task_num
  5017.     lea    shelline(a5),a2
  5018. .B    move.b    (a2)+,(a1)+
  5019.     bne.s    .B
  5020.     lea    -1(a1),a1
  5021.     bra    cpro3
  5022. try_task_num
  5023.     cmp.b    #'n',d0        check if %n
  5024.     bne.s    composer2
  5025.     move.l    thistask(a5),a2
  5026.     move.l    pr_TaskNum(a2),d0
  5027.     add.b    #$30,d0
  5028. composer2    move.b    d0,(a1)+
  5029.     cmp.b    #LF,d0
  5030.     bne.s    .A
  5031.     move.l    a1,prompt_cr(a5)
  5032. .A    bra    cpro3
  5033. composer3    lea    farb1(pc),a0
  5034. .A    move.b    (a0)+,(a1)+
  5035.     bne.s    .A
  5036.     rts
  5037.  
  5038.  
  5039. *FILL FIB WITH EXAMINE A0-> directory name ,D7=filelock on return
  5040. fibexam    move.l    a0,-(sp)
  5041.     moveq    #ACCESS_READ,d2
  5042.     move.l a0,d1
  5043.     jsr    _LVOLock(a6)
  5044.     move.l    d0,d7
  5045.     beq    DOSerr
  5046.     bsr    fibexam2
  5047.     move.l    (sp)+,a0
  5048.     rts
  5049. fibexam2
  5050.     move.l    d0,d1
  5051.     move.l    a5,d2
  5052.     jsr    _LVOExamine(a6)
  5053.     tst.l    d0
  5054.     beq    DOSerrUL
  5055.     rts
  5056.  
  5057. *****************
  5058. *    CD    *
  5059. *****************
  5060. cdz    tst.l    parm2(a5)
  5061.     beq    querycd
  5062.     move.l    parm2(a5),a0
  5063. chdir    * check and change directory, a0=dirname
  5064.     move.l    d7,-(sp)
  5065.     bsr    fibexam
  5066.     move.l    d7,d1
  5067.     move.l    (sp)+,d7
  5068.     tst.l    fib_DirEntryType(a5)    ;check entry OK
  5069.     bpl.s    .A
  5070.     jsr    _LVOUnLock(a6)
  5071.     move.l    #212,d0
  5072.     bra    pr_galactic
  5073. *CHANGE DIRECTORY d1:lock to new current directory
  5074. .A    move.l    d1,a0
  5075.     add.l    a0,a0
  5076.     add.l    a0,a0
  5077.     move.l    thistask(a5),a1
  5078.     move.l    fl_Task(a0),pr_FileSystemTask(a1)
  5079.     jsr    _LVOCurrentDir(a6)
  5080.     move.l    d0,d1
  5081.     jsr    _LVOUnLock(a6)    unlock the old directory
  5082.     lea    CD_string+1(a5),a0
  5083.     lea    CDbackstr(a5),a1
  5084. .B    move.b    (a0)+,(a1)+    remember old directory
  5085.     bne.s    .B
  5086.     bsr    eval_CD        update cd string
  5087.     moveq    #RETURN_OK,d0
  5088.     rts
  5089.     
  5090. querycd    bsr    eval_CD
  5091.     lea    CD_string+1(a5),a1
  5092.     bsr    pr_stringlf
  5093.     moveq    #RETURN_OK,d0
  5094.     rts
  5095.  
  5096.  
  5097. ** Evaluate entire name of current directory and put in CD_string
  5098. eval_CD    clr.b    CD_string+1(a5)
  5099.     lea    null(pc),a0
  5100.     move.l    a0,d1
  5101.     moveq    #ACCESS_READ,d2
  5102.     jsr    _LVOLock(a6)
  5103.     tst.l    d0
  5104.     beq.s    .A
  5105.     move.l    d0,a0
  5106.     add.l    a0,a0
  5107.     add.l    a0,a0
  5108.     move.l    fl_Key(a0),cd_block(a5)
  5109.     move.l    fl_Volume(a0),cd_volnode(a5)
  5110.     lea    CD_string+1(a5),a0
  5111.     bsr    eval_full_path
  5112.     jsr    _LVOUnLock(a6)
  5113. .A    moveq    #-1,d0
  5114.     lea    CD_string(a5),a0
  5115.     lea    1(a0),a1
  5116. .B    addq.b    #1,d0    calculate size of BSTR
  5117.     tst.b    (a1)+
  5118.     bne.s    .B
  5119.     move.b    d0,(a0)
  5120.     rts
  5121.     
  5122. ** evaluate entire name associated with lock in D0, store string in A0
  5123. ** Return D1 = last lock to unlock
  5124. ** Reg usage: d0,d1,d2,d3,a0,a1,a3 (must not use A2)
  5125. eval_full_path
  5126.     move.b    #"?",(a0)
  5127.     clr.b    1(a0)
  5128.     move.l    d0,d1
  5129.     beq.s    .C
  5130.     lsl.l    #2,d0
  5131.     move.l    d0,a1
  5132.     moveq    #ACCESS_READ,d0
  5133.     cmp.l    fl_Access(a1),d0    only eval read locks
  5134.     bne.s    .B
  5135. .C    cmp.w    #36,kickver(a5)
  5136.     blo.s    .A
  5137.     move.l    d1,a3
  5138.     move.l    a0,d2
  5139.     moveq    #78,d3
  5140.     jsr    _LVONameFromLock(a6)
  5141.     move.l    a3,d1
  5142. .B    rts
  5143. .A    lea    -88(sp),sp
  5144.     move.l    a0,4(sp)        save address of string
  5145.     move.l    d1,(sp)        save original lock on stack
  5146.     move.l    a5,d2
  5147.     jsr    _LVOExamine(a6)
  5148.     move.l    4(sp),a1
  5149.     lea    fib_FileName(a5),a0
  5150. evx1    move.b    (a0)+,(a1)+    COPY FILENAME TO deststring
  5151.     bne.s    evx1
  5152.     lea    -1(a1),a3
  5153. evcd2    move.l    (sp),d1        get lock
  5154.     jsr    _LVOParentDir(a6)
  5155.     tst.l    d0
  5156.     beq.s    root_found
  5157.     move.l    (sp),d1
  5158.     move.l    d0,(sp)
  5159.     jsr    _LVOUnLock(a6)    unlock last
  5160.     move.l    (sp),d1
  5161.     move.l    a5,d2
  5162.     jsr    _LVOExamine(a6)
  5163.     lea    fib_FileName(a5),a0
  5164.     lea    8(sp),a1
  5165. evx2    move.b    (a0)+,(a1)+    stackbuf = filename
  5166.     bne.s    evx2
  5167.     move.b    #'/',-1(a1)
  5168.     move.l    4(sp),a0
  5169. evx3    move.b    (a0)+,(a1)+    stackbuf = filename/CD_string
  5170.     bne.s    evx3
  5171.     move.l    4(sp),a1
  5172.     lea    8(sp),a0
  5173. evx4    move.b    (a0)+,d0
  5174.     move.b    d0,(a1)+
  5175.     cmp.b    #'/',d0
  5176.     bne.s    evx4
  5177.     lea    -1(a1),a3
  5178. evx5    move.b    (a0)+,(a1)+    dest string = stackbuf
  5179.     bne.s    evx5
  5180.     bra    evcd2
  5181. root_found
  5182.     move.l    (sp),d1
  5183.     tst.b    (a3)
  5184.     bne.s    root2
  5185.     clr.b    1(a3)
  5186. root2    move.b    #':',(a3)
  5187.     lea    88(sp),sp
  5188.     rts
  5189.  
  5190. *ADDPATH A0-> path  A1-> parameter  A2-> destination for string
  5191. ** eg. (A0)='df0:libs',0  (A1)='arp.library',0  (A2)='df0:libs/arp.library',0
  5192. addpath    movem.l a0-a2,-(sp)
  5193.     move.b (a0),d0
  5194.     beq.s addp4
  5195. addp1    move.b (a0)+,d0
  5196.     beq.s addp2
  5197.     move.b d0,(a2)+
  5198.     bra.s addp1
  5199. addp2    move.b -2(a0),d0
  5200.     cmp.b #':',d0
  5201.     beq.s addp4
  5202.     cmp.b #'/',d0
  5203.     beq.s addp4
  5204.     move.b #'/',(a2)+
  5205. addp4    move.l a1,a0
  5206.     move.l a2,a1
  5207.     bsr cp_string
  5208.     movem.l (sp)+,a0-a2
  5209.     rts
  5210.  
  5211.  
  5212. * Search Resident list for command    V2.0:Global resi's
  5213. * RETURN D0=seglist OR 0 if not found
  5214. *    A0=addr of node        D2=addr of VorgΣnger
  5215. search_res    move.l    parm1(a5),a4
  5216. search_res2
  5217.     bsr    resi_hand
  5218.     beq.s    .D
  5219.     move.l    a0,d2
  5220. .A    lsl.l    #2,d0
  5221.     move.l    a4,a1            string
  5222.     move.l    d0,a2
  5223.     lea    resi_name(a2),a0    BSTR
  5224.     moveq    #0,d3
  5225.     move.b    (a0)+,d3
  5226.     subq.w    #1,d3
  5227. .B    move.b    (a0)+,d0
  5228.     move.b    (a1)+,d1
  5229.     cmp.b    dotchar(a5),d1
  5230.     bne.s    .F
  5231.     tst.b    (a1)
  5232.     beq.s    .C
  5233. .F    bsr    compD1D0locale
  5234.     dbne    d3,.B
  5235.     bne.s    .E    not equal
  5236.     tst.b    (a1)
  5237.     beq.s    .C    the (null-)END
  5238. .E    move.l    a2,d2
  5239.     move.l    resi_link(a2),d0    get link
  5240.     bne.s    .A
  5241. .D    moveq    #0,d0
  5242.     rts
  5243. .C    moveq    #-1,d1
  5244.     cmp.l    resi_usecount(a2),d1    is it a system-resi ?
  5245.     beq.s    .D
  5246.     move.l    resi_seglist(a2),d0    get seglist
  5247.     move.l    a2,a0
  5248.     rts
  5249.  
  5250.  
  5251. *Search paths for command
  5252. *Exit: d0=seglist, d4=PROGDIR:, branches if script file
  5253. spaths    move.l    parm1(a5),a4    A4=parm1
  5254. spaths2    moveq    #0,d4    jump-in for resident,do not load scripts with it!
  5255.     move.l    thistask(a5),a3
  5256.     lea    pr_CurrentDir(a3),a3    (A3)=ptr to current dir
  5257.     move.l    (a3),d3            d3=current dir at beginning
  5258.     move.l    d3,d4            d4=PROGDIR:
  5259.     bsr    lock_or_load
  5260.     tst.l    d0
  5261.     bmi.s    .C        not found
  5262.     bne    gotit        found & executable
  5263.     tst.b    forcediskflag(a5)
  5264.     bne.s    .C        do not change dir
  5265.     tst.l    fib_DirEntryType(a5)    is it a DIR ?
  5266.     bmi    s_flagset    no, exec script ?
  5267.     tst.l    parm2(a5)
  5268.     bne.s    .C        argument given: do not change dir
  5269.     addq.l    #4,sp        return from archie3
  5270.     move.l    a4,a0
  5271.     bra    chdir        change current dir
  5272.  
  5273. .C    move.l    a4,a0
  5274. .F    move.b    (a0)+,d0    are there path-specific chars in the name
  5275.     cmp.b    #"/",d0
  5276.     beq.s    no_more_paths
  5277.     cmp.b    #":",d0
  5278.     beq.s    no_more_paths
  5279.     tst.b    d0
  5280.     bne.s    .F
  5281.     bsr    RequestersOff        no requesters
  5282.     move.l    CLIptr(a5),a2
  5283.     lea    cli_CommandDir(a2),a2    A2=ptr to current path
  5284.  
  5285. .A    move.l    (a2),d0        search all paths
  5286.     beq.s    no_more_paths
  5287.     lsl.l    #2,d0
  5288.     move.l    d0,a2
  5289.     move.l    4(a2),d4    d4=PROGDIR:
  5290.     beq.s    .A
  5291.     move.l    d4,(a3)
  5292.     bsr    lock_or_load    disk access
  5293.     tst.l    d0
  5294.     bmi.s    .A
  5295.     bne.s    gotit
  5296.     tst.l    fib_DirEntryType(a5)    is it a DIR ?
  5297.     bpl.s    .A
  5298.     bra.s    s_flagset    exec script
  5299. no_more_paths
  5300.     moveq    #0,d0
  5301. gotit    move.l    d3,(a3)        restore current dir
  5302.     bra    RequestersOn
  5303.  
  5304. lock_or_load
  5305.     move.l    a4,d1
  5306.     moveq    #ACCESS_READ,d2
  5307.     jsr    _LVOLock(a6)
  5308.     move.l    d0,d7
  5309.     bne.s    .A
  5310.     moveq    #-1,d0        file not found
  5311.     rts
  5312. .A    bsr    fibexam2
  5313.     moveq    #0,d0
  5314.     tst.l    fib_DirEntryType(a5)
  5315.     bpl.s    .C
  5316.     move.l    fib_Protection(a5),d1
  5317.     btst    #6,d1    script-bit ?
  5318.     bne.s    .C
  5319.     btst    #1,d1    not-execute-bit ?
  5320.     bne.s    .C
  5321.     move.l    a4,d1
  5322.     jsr    _LVOLoadSeg(a6)
  5323. .C    move.l    d0,-(sp)
  5324.     move.l    d7,d1
  5325.     jsr    _LVOUnLock(a6)
  5326.     move.l    (sp)+,d0
  5327.     rts
  5328.  
  5329. s_flagset
  5330.     move.l    d3,(a3)        restore current dir
  5331.     bsr    RequestersOn
  5332.     addq.l    #4,sp    kill return addresses (archie3,spaths)
  5333.     move.l    fib_Protection(a5),d1
  5334.     btst    #6,d1
  5335.     beq.s    .A
  5336.     addq.l    #4,sp    kill return addresses (archie3,spaths)
  5337.     move.l    a4,a0    A4 pts to filename
  5338.     bsr    readfile
  5339.     move.l    d3,(a3)        restore current dir
  5340.     bra    xz3
  5341. .A    move.l    #305,d0
  5342.     tst.l    parm2(a5)    argument given: do not show file
  5343.     bne.s    .E
  5344.     cmp.l    d3,d4        PROGDIR=Current Dir ?
  5345. .E    bne    pr_DOSerr    NO: file not executable
  5346. ;show ascii or amigaguide text
  5347.     move.l    4.w,a6        YES: show it with Amigaguide
  5348.     lea    guidename(pc),a1
  5349.     jsr    _LVOOldOpenLibrary(a6)
  5350.     tst.l    d0
  5351.     beq.s    .C        opened amigaguide.library ?
  5352.     move.l    d0,a6
  5353.     moveq    #NewAmigaGuide_SIZEOF/4-1,d0
  5354. .D    clr.l    -(sp)
  5355.     dbra    d0,.D
  5356.     move.l    a4,nag_Name(sp)    filename into nag
  5357.     move.l    sp,a0        nag to a0
  5358.     sub.l    a1,a1        must be zero
  5359.     jsr    _LVOOpenAmigaGuideA(a6)    open guide
  5360.     tst.l    d0
  5361.     beq.s    .B        failed to open guide ?
  5362.     move.l    d0,a0
  5363.     jsr    _LVOCloseAmigaGuide(a6)    wait till user closes guide
  5364. .B    lea    NewAmigaGuide_SIZEOF(sp),sp
  5365.     move.l    a6,a1        Free library
  5366.     move.l    4.w,a6
  5367.     jsr    _LVOCloseLibrary(a6)
  5368. .C    move.l    dosbase(a5),a6
  5369.     rts
  5370.  
  5371.  
  5372. * ARCHIE 3 calls system0 to execute non internal commands
  5373. archie3    tst.l    parm1(a5)        exit if nothing typed
  5374.     beq    noarch31
  5375.     clr.b    resi_flag(a5)        =0 if resident
  5376.     bsr    search_res        search resident list first
  5377.     tst.l    d0
  5378.     bne.s    .A
  5379.     addq.b    #1,resi_flag(a5)    =1 if not resident
  5380.     bsr    spaths            load the command
  5381.     tst.l    d0
  5382.     beq    noarch32        could not load
  5383.     cmp.w    #36,kickver(a5)
  5384.     blo.s    .A
  5385.     move.l    thistask(a5),a3
  5386.     move.l    d4,pr_HomeDir(a3)    init PROGDIR:
  5387. .A    move.l    d0,temp1(a5)        save the segment
  5388.     bsr    save_mem_time
  5389.     lea    CLIbuf(a5),a0
  5390.     move.l    a0,-(sp)    push arg_args ptr.
  5391.     move.l    d0,-(sp)    push seglist
  5392.     move.l    parm1(a5),d0
  5393.     move.l    d0,-(sp)    push arg_name
  5394.     bsr    _System0    TAKES 3 PARMS(ARG_NAME,SEGLIST,ARGS)
  5395.     lea    12(sp),sp
  5396.     move.l    d0,-(sp)
  5397.     cmp.w    #36,kickver(a5)
  5398.     blo.s    .G
  5399.     move.l    thistask(a5),a3
  5400.     clr.l    pr_HomeDir(a3)        reset PROGDIR:
  5401. .G    jsr    _LVOIoErr(a6)
  5402.     move.l    d0,Result2(a5)
  5403.     btst    #FLcheck,Flags+3(a5)
  5404.     beq.s    .C
  5405.     bsr    show_status
  5406. .C    tst.b    resi_flag(a5)
  5407.     beq.s    .B
  5408.     move.l    better_Seglist(a5),d1
  5409.     jsr    _LVOUnLoadSeg(a6)
  5410. .B    move.l    (sp)+,d2    RESULT IN D2
  5411.     beq.s    .D
  5412.     btst    #FLerrors,Flags+3(a5)
  5413.     beq.s    .D
  5414.     move.l    Result2(a5),d0
  5415.     beq.s    .D
  5416.     bsr    pr_DOSerr    if result > 0 print error
  5417. .D    move.l    d2,d0    
  5418. noarch31    rts
  5419. noarch32
  5420.     moveq    #-121,d0        command not found
  5421.     bsr    pr_DOSerr
  5422.     moveq    #RETURN_BAD,d0        return d0 bad
  5423.     rts
  5424.  
  5425.  
  5426. *****    SYSTEM0 execute command from disk. From Sozobon C distribution.
  5427. * Copyright ⌐ 1988 by Ralph Babel.
  5428. *
  5429. * This piece of code may be used as part of any product as
  5430. * long as the source code for the complete program can be
  5431. * obtained free of charge (except for a small copying fee)
  5432. * and this copyright notice is left unchanged.
  5433. _System0
  5434.     movem.l    d2-d3/a2-a6,-(sp)    ;SAVED_REGS
  5435.     moveq    #NO_CLI,REG_Result      ;#-1,d3 ERROR - not a CLI task
  5436.     move.l    4.w,REG_SysBase    ;4,a6
  5437.     move.l    thistask(a5),REG_Process    ;a2
  5438.     move.l    pr_CLI(REG_Process),d0
  5439.     beq    quit0
  5440.  
  5441. * build local stack frame & save some values
  5442.     lsl.l    #2,d0
  5443.     move.l    d0,REG_CLI    ;a3
  5444.     move.l    sp,REG_PrevStack        ;a1 save old stack pointer
  5445.     move.l    sp,d0
  5446.     and.b    #$fc,d0 ;make SP longword-aligned for BPTRs
  5447.     move.l    d0,sp
  5448.     sub.l    #sf_SIZEOF,sp    ;stack-frame-struct
  5449.     move.l    REG_PrevStack,sf_PrevStack(sp)
  5450.     move.l    REG_Process,sf_Process(sp)
  5451.     move.l    REG_CLI,sf_CLI(sp)
  5452.     move.l  pr_ReturnAddr(REG_Process),sf_SaveReturnAddr(sp)
  5453.  
  5454. * allocate space for stack
  5455.     moveq    #NO_MEM,REG_Result    ;ERROR - no memory for STACK
  5456.     move.l    cli_DefaultStack(REG_CLI),d0    ;in longwords for "VEC"
  5457.     lsl.l    #2,d0
  5458.     move.l    d0,sf_PushSize(sp)
  5459.     addq.l    #4,d0    ;one additional longword
  5460.     move.l    d0,sf_StackSize(sp)
  5461.     moveq    #1,d1    ;intentionally NOT "MEMF_PUBLIC"!; V2.0 Why not ?
  5462.     callsys    AllocMem
  5463.     tst.l    d0
  5464.     beq    quit1
  5465.     move.l    d0,sf_StackBase(sp)    ;save result
  5466.  
  5467. * save old command pointer, build new BCPL command name
  5468.     move.l    cli_CommandName(REG_CLI),sf_SaveCommandName(sp)
  5469.     move.l    sf_PrevStack(sp),REG_PrevStack
  5470.     move.l    ARG_NAME(REG_PrevStack),a0 ;first parameter to "System0()"
  5471.     lea    sf_CommandName(sp),a1 ;BSTR
  5472.     move.w    #MAXBSTR-2,d0
  5473.     bsr    cpBSTR
  5474.     move.l    d0,cli_CommandName(REG_CLI)
  5475. * save contents of Current Input Stream
  5476.     move.l    pr_CIS(REG_Process),d0
  5477.     lsl.l    #2,d0
  5478.     move.l    d0,REG_CIS
  5479.     move.l    REG_CIS,sf_CIS(sp)
  5480.     move.l    fh_Buf(REG_CIS),sf_SCB_Buf(sp)
  5481.     move.l    fh_Pos(REG_CIS),sf_SCB_Pos(sp)
  5482.     move.l    fh_End(REG_CIS),sf_SCB_End(sp)
  5483. tst
  5484. * convert argument to LF-terminated string
  5485.     move.l    sf_PrevStack(sp),REG_PrevStack
  5486.     move.l    ARG_ARGS(REG_PrevStack),a0 ;third argument to "System0()"
  5487.     lea    sf_CommandArgs(sp),a1    ;first buffer location
  5488.     move.l    a1,d0
  5489.     lsr.l    #2,d0
  5490.     move.l    d0,fh_Buf(REG_CIS)
  5491.     move.w    #MAXBSTR-1,d0    ;leave some room for terminating LF
  5492.     bra.s    .D
  5493. .C    move.b    d1,(a1)+
  5494. .D    move.b    (a0)+,d1
  5495.     dbeq    d0,.C
  5496.     move.b    #LF,(a1)
  5497.     move.l    sf_PrevStack(sp),REG_PrevStack
  5498.     sub.l    ARG_ARGS(REG_PrevStack),a0    ;subtract first position
  5499.     move.l    a0,d0    ;do NOT subtract 1, LF need this byte
  5500. * setup start/end indices in Stream Control Block
  5501.     clr.l   fh_Pos(REG_CIS)
  5502.     move.l  d0,fh_End(REG_CIS)
  5503.  
  5504. * misc setup
  5505.     clr.l    pr_Result2(REG_Process)    ;clear secondary result
  5506.     move.l    a5,sf_Membase(sp)    ;save membase
  5507. ;    moveq    #0,d0
  5508. ;    moveq    #0,d1
  5509. ;    bset    #SIGBREAKB_CTRL_C,d1
  5510. ;    callsys    SetSignal    ;clear CTRL-C flag
  5511.  
  5512. * handle seglist and start address
  5513.     move.l    cli_Module(REG_CLI),sf_SaveModule(sp)
  5514.     move.l    sf_PrevStack(sp),REG_PrevStack
  5515.     move.l    ARG_SEGLIST(REG_PrevStack),d0 ;second argument to "System0()"
  5516.     move.l    d0,cli_Module(REG_CLI)
  5517.     lsl.l    #2,d0
  5518.     move.l    d0,a3
  5519. * setup processor registers & C-interface
  5520.     lea    sf_CommandArgs(sp),a0
  5521.     move.l    fh_End(REG_CIS),d0
  5522. * setup processor registers, BCPL-interface, stack & return address for "Exit()"
  5523.     move.l    sf_StackBase(sp),a1    ;BCPL stack, low end
  5524.     move.l    sf_PushSize(sp),d2
  5525.     lea    4(a1,d2.l),a4    ;must not destroy REG_Process!
  5526.     move.l    sp,-(a4)    ;previous stack frame
  5527.     move.l    d2,-(a4)    :stack size in bytes
  5528.     move.l    a4,pr_ReturnAddr(REG_Process)
  5529.     move.l    a4,sp
  5530.     move.l    dosbase(a5),a4    ;V2.0 small data
  5531.     movem.l    dl_A2(a4),a2/a5/a6
  5532.  
  5533. * now call the command at its entry point
  5534.     jsr    4(a3)    ;code starts one longword behind segment pointer
  5535.     move.l    d0,REG_Result    ;save return code
  5536.  
  5537. * get old stackframe & reload old register contents
  5538.     move.l    4(sp),sp    ;old stack frame
  5539.     move.l    sf_Membase(sp),a5
  5540.     move.l    sf_Process(sp),a0
  5541.     move.l    sf_SaveReturnAddr(sp),pr_ReturnAddr(a0)
  5542.     move.l    sf_CIS(sp),d0
  5543.     move.l    d0,a1
  5544.     lsr.l    #2,d0
  5545.     move.l    d0,pr_CIS(a0)    ;V2.0 restore CIS
  5546.     move.l    sf_CLI(sp),a0
  5547.     move.l    sf_SaveCommandName(sp),cli_CommandName(a0)
  5548. * Next line makes powerpacker programs deallocate memory properly
  5549.     move.l    cli_Module(a0),better_Seglist(a5)    ;V2.0 small data
  5550.     move.l    sf_SaveModule(sp),cli_Module(a0)
  5551. * restore original contents of Current Input Stream
  5552.     move.l    sf_CIS(sp),a0
  5553.     lea    sf_CommandArgs(sp),a1
  5554.     move.l    a1,d0
  5555.     lsr.l    #2,d0
  5556.     cmp.l    fh_Buf(a0),d0    ;still the same?
  5557.     bne.s    .E    ;no: don't restore
  5558.     move.l    sf_SCB_Buf(sp),fh_Buf(a0)
  5559. .E    move.l    sf_SCB_Pos(sp),fh_Pos(a0)
  5560.     tst.l    fh_End(a0)    ;end index set?
  5561.     beq.s    .F    ;no: don't restore
  5562.     move.l    sf_SCB_End(sp),fh_End(a0)
  5563.  
  5564. * free temporary stack
  5565. .F    move.l    4.w,REG_SysBase
  5566.     move.l    sf_StackBase(sp),a1
  5567.     move.l    sf_StackSize(sp),d0
  5568.     callsys    FreeMem
  5569.  
  5570. quit1    move.l    sf_PrevStack(sp),sp    ;UNLINK local variables
  5571. quit0    move.l    REG_Result,d0
  5572.     movem.l    (sp)+,d2-d3/a2-a6    ;SAVED_REGS
  5573. quitx    rts
  5574.  
  5575.  
  5576. *************************
  5577. *    HELP        *
  5578. *************************
  5579. helpz    bsr    pr_hide_cursor
  5580.     move.l    parm2(a5),d7
  5581.     bne    help_man
  5582.     lea    helptx1(pc),a1
  5583.     bsr    pr_stringlf
  5584.     lea    comtext(pc),a4
  5585.     lea    tempbuf(a5),a3
  5586. .D    moveq    #5,d3
  5587. .C    move.l    a3,a2
  5588.     addq.l    #1,a4
  5589.     tst.b    (a4)        
  5590.     beq    .E
  5591.     moveq    #12,d2
  5592. .B    subq.l    #1,d2
  5593.     move.b    (a4)+,(a2)+
  5594.     bne.s    .B
  5595.     tst.b    -(a2)    bump    back
  5596. .A    move.b    #$20,(a2)+
  5597.     dbra    d2,.A
  5598.     clr.b    (a2)
  5599.     move.l    a3,a1
  5600.     bsr    pr_string
  5601.     dbra    d3,.C
  5602.     bsr    pr_lf
  5603.     bra    .D
  5604. .E    bsr    pr_lf
  5605. ;    bsr    pr_lf
  5606.     lea    helptx2(pc),a4
  5607.     lea    helptx3(pc),a0
  5608.     move.l    a0,d6
  5609.     bsr    pr_screen
  5610.     moveq    #RETURN_OK,D0
  5611.     rts
  5612.  
  5613. * print out part of manual, d7 points to topic
  5614. help_man
  5615.     bsr    pr_hide_cursor
  5616.     lea    manadr(pc),a2    global variable
  5617.     move.l    4(a2),d1
  5618.     move.l    (a2),d0
  5619.     bne.s    .A
  5620.     lea    helpld(pc),a1
  5621.     bsr    pr_string
  5622.     bsr    pr_lf
  5623.     move.l    online_help(a5),a0
  5624.     bsr    readfile    load manual
  5625.     move.l    d0,(a2)        manadr
  5626.     move.l    d1,4(a2)    mansize
  5627. .A    move.l    d0,a3
  5628.     move.l    d1,d5
  5629.     add.l    a3,d5
  5630.     move.l    a3,a2
  5631.     moveq    #0,d4
  5632.     tst.l    d7
  5633.     beq    make_screen    type all !
  5634. .B    move.l    d7,a1
  5635.     move.l    d5,a0
  5636.     addq.l    #1,a2
  5637.     bsr    searchSTR    search topic in manual
  5638.     cmp.b    #LF,d0
  5639.     bne.s    .C
  5640.     cmp.b    #"=",-6(a2)    there must be a lot of "=" before topic
  5641.     bne.s    .B
  5642.     cmp.b    #"=",-7(a2)    leave room for underlined sequence
  5643.     bne.s    .B
  5644.     cmp.b    #LF,-1(a2)
  5645.     beq.s    .F
  5646.     cmp.b    #"m",-1(a2)
  5647.     bne.s    .B
  5648. .F    move.l    a1,d4
  5649. .E    bsr    check_c        ctrl-c ?
  5650.     bne.s    .C
  5651. .D    cmp.l    d5,a1
  5652.     bhi.s    .C
  5653.     cmp.b    #LF,(a1)+    print lines separately
  5654.     bne.s    .D
  5655.     move.l    d4,d2
  5656.     move.l    a1,d3
  5657.     sub.l    d2,d3
  5658.     move.l    a1,d4
  5659.     move.l    outhandle(a5),d1
  5660.     jsr    _LVOWrite(a6)
  5661.     move.l    d4,a1
  5662.     cmp.b    #"=",-2(a1)    search next lot of "="
  5663.     bne.s    .E
  5664.     cmp.b    #"=",-3(a1)
  5665.     bne.s    .E
  5666.     bra.s    .B        another fitting topic ?
  5667. .C    moveq    #RETURN_OK,D0
  5668.     rts
  5669.  
  5670. giveman    movem.l    d0/d1/a0/a1,-(sp)    free manual-memory
  5671.     lea    manadr(pc),a0
  5672.     tst.l    (a0)
  5673.     beq.s    .A
  5674.     move.l    (a0),a1
  5675.     clr.l    (a0)
  5676.     move.l    4(a0),d0
  5677.     bsr    givemem
  5678. .A    movem.l    (sp)+,d0/d1/a0/a1
  5679.     rts
  5680.  
  5681.  
  5682. * PRINT A STRING BUT PUT A LINEFEED AFTER IT
  5683. pr_stringlf    bsr pr_string
  5684.         bra pr_lf
  5685.  
  5686. *****************    
  5687. *    PATH    *     Assign path or show it.
  5688. *****************
  5689. pathz    lea    parm2(a5),a3
  5690.     move.l    (a3),d0        see whether any parameters
  5691.     beq    ShowPaths
  5692.     move.l    CLIptr(a5),a4
  5693.     lea    cli_CommandDir(a4),a4
  5694.     move.l    d0,a0
  5695.     bsr    return_dash_option
  5696.     cmp.b    #"C",d0
  5697.     bne.s    .F
  5698.     bsr    DeletePaths    * remove all paths
  5699.     addq.l    #4,a3
  5700.  
  5701. .F    moveq    #-1,d3        reverse order
  5702. .G    addq.l    #1,d3
  5703.     tst.l    (a3)+
  5704.     bne.s    .G
  5705.     subq.l    #4,a3
  5706.     bra.s    .D
  5707. .C    move.l    -(a3),d1
  5708.     moveq    #ACCESS_READ,d2    * add as many paths as given
  5709.     jsr    _LVOLock(a6)    get a lock
  5710.     move.l    d0,d2
  5711.     beq    DOSerr
  5712.     bsr    CreatePath
  5713.     beq    resi_no_mem
  5714. .D    dbra    d3,.C
  5715.     moveq    #RETURN_OK,d0
  5716.     rts
  5717.  
  5718. DeletePaths    ;a4=cli_CommandDir, removes all paths
  5719.     move.l    a2,-(sp)
  5720.     move.l    a4,a2
  5721. .A    move.l    (a2),d0
  5722.     beq.s    .B
  5723.     lsl.l    #2,d0
  5724.     move.l    d0,a2
  5725.     move.l    4(a2),d1
  5726.     beq.s    .A
  5727.     jsr    _LVOUnLock(a6)    unlock all paths
  5728.     bra.s    .A
  5729. .B    move.l    (a4),d1
  5730.     beq.s    .E
  5731.     jsr    _LVOUnLoadSeg(a6)    free memory
  5732.     tst.l    d0
  5733.     beq    DOSerr
  5734.     clr.l    (a4)        set path ptr to nil
  5735. .E    move.l    (sp)+,a2
  5736.     rts
  5737.  
  5738. CreatePath    ;d2=Lock, a4=cli_CommandDir
  5739.     moveq    #12,d0
  5740.     bsr    iwantmem    create seglist
  5741.     bsr    maybeDOSerr
  5742.     beq.s    .A
  5743.     move.l    d0,a0
  5744.     addq.l    #4,d0
  5745.     lsr.l    #2,d0
  5746.     moveq    #12,d1
  5747.     move.l    d1,(a0)        size of seglist
  5748.     move.l    (a4),4(a0)    link the new path
  5749.     move.l    d2,8(a0)    bptr to lock
  5750.     move.l    d0,(a4)        first in path-list
  5751. .A    rts
  5752.  
  5753. ShowPaths
  5754.     bsr    pr_hide_cursor
  5755.     move.l    #-152,d0
  5756.     bsr    GetMessage
  5757.     move.l    a0,a1
  5758.     bsr    pr_stringlf
  5759.     move.l    CLIptr(a5),a0
  5760.     lea    cli_CommandDir(a0),a2
  5761. .A    move.l    (a2),d0
  5762.     beq.s    .B
  5763.     lsl.l    #2,d0
  5764.     move.l    d0,a2
  5765.     move.l    4(a2),d1
  5766.     beq.s    .A
  5767.     jsr    _LVODupLock(a6)
  5768.     tst.l    d0
  5769.     beq.s    .A
  5770.     lea    tempbuf(a5),a0
  5771.     bsr    eval_full_path
  5772.     jsr    _LVOUnLock(a6)
  5773.     lea    tempbuf(a5),a1
  5774.     bsr    pr_stringlf
  5775.     bra.s    .A
  5776. .B    moveq    #RETURN_OK,d0
  5777.     rts
  5778.  
  5779. CopyPaths    ;copy paths from task in a0 to this task
  5780.     movem.l    d2-d3/a2-a4,-(sp)
  5781.     move.l    thistask(a5),a4
  5782.     move.l    pr_CLI(a4),d0
  5783.     beq.s    .D
  5784.     lsl.l    #2,d0
  5785.     move.l    d0,a4
  5786.     lea    cli_CommandDir(a4),a4
  5787.     move.l    pr_CLI(a0),d0
  5788.     beq.s    .D
  5789.     lsl.l    #2,d0
  5790.     move.l    d0,a0
  5791.     lea    cli_CommandDir(a0),a2
  5792.     lea    tempbuf(a5),a3
  5793.     moveq    #0,d3
  5794. .A    move.l    (a2),d0        * walk through all paths
  5795.     beq.s    .C
  5796.     lsl.l    #2,d0
  5797.     move.l    d0,a2
  5798.     move.l    4(a2),d1
  5799.     beq.s    .A
  5800.     move.l    d1,(a3)+
  5801.     addq.l    #1,d3
  5802.     bra.s    .A
  5803. .B    move.l    -(a3),d1
  5804.     jsr    _LVODupLock(a6)    copy lock
  5805.     move.l    d0,d2
  5806.     beq.s    .C
  5807.     bsr    CreatePath    add path
  5808. .C    dbra    d3,.B
  5809. .D    movem.l    (sp)+,d2-d3/a2-a4    return
  5810.     rts
  5811.  
  5812. *****************
  5813. *    INFO    *
  5814. *****************
  5815. infoz    bsr    pr_hide_cursor    ;V2.0 (fully new)
  5816.     lea    inform_tx(pc),a1
  5817.     bsr    pr_stringlf
  5818.     move.l    $22(a6),a0    ;rootnode
  5819.     move.l    $18(a0),a0    ;dosinfo
  5820.     add.l    a0,a0
  5821.     add.l    a0,a0
  5822.     move.l    4(a0),d6    ;devicelist
  5823. jajo    tst.l    d6
  5824.     bne    .B
  5825.     moveq    #RETURN_OK,d0
  5826.     rts
  5827.  
  5828. .B    lsl.l    #2,d6    ;BPTR
  5829.     move.l    d6,a4
  5830.     move.l    (a4),d6        ;next
  5831.     tst.l    4(a4)        ;type
  5832.     bne.s    jajo    ;was volume or assign
  5833.     tst.l    8(a4)        ;task
  5834.     beq.s    jajo    ;was non-disk-device
  5835. didev    move.l    $28(a4),a0    ;name
  5836.     add.l    a0,a0
  5837.     add.l    a0,a0
  5838.     moveq    #0,d0
  5839.     move.b    (a0)+,d0
  5840.     lea    tempbuf(a5),a3
  5841.     move.l    a3,a2
  5842.     bra.s    .D
  5843. .C    move.b    (a0)+,(a2)+
  5844. .D    dbra    d0,.C
  5845.     move.b    #":",(a2)+
  5846.     clr.b    (a2)
  5847.     move.l    8(a4),packettask(a5)    ;aptr task
  5848.     bsr    GetDiskInfo
  5849.     bne    .A        check for error
  5850.     move.l    sp_res2(a5),d0
  5851.     cmp.l    #209,d0
  5852.     beq.s    jajo
  5853.     bsr    pr_DOSerr
  5854.     bra.s    jajo
  5855. .A    bsr    do_forbid
  5856.     move.l    id_DiskType(a5),d1
  5857.     move.l    d1,d0
  5858.     clr.b    d0
  5859.     cmp.l    #"DOS"<<8,d0
  5860.     beq.s    itsDos        ;DOS-Disk
  5861.     move.l    #226,d0
  5862.     moveq    #-1,d2
  5863.     cmp.l    d1,d2
  5864.     beq.s    .F
  5865.     subq.l    #1,d0
  5866.     cmp.l    #"BAD"<<8,d1
  5867.     beq.s    .F
  5868.     cmp.l    #"NDOS",d1
  5869.     beq.s    .F
  5870.     lea    kickdisk(pc),a0
  5871.     cmp.l    #"KICK",d1
  5872.     beq.s    .G
  5873.     move.l    #213,d0
  5874. .F    bsr    GetMessage
  5875. .G    move.l    a0,-(sp)
  5876.     move.l    id_UnitNumber(a5),-(sp)
  5877.     move.l    a3,-(sp)
  5878.     bsr    do_permit
  5879.     lea    (sp),a1
  5880.     lea    inform2(pc),a0
  5881.     bsr    new_print
  5882.     lea    12(sp),sp
  5883.     bra    jajo
  5884.  
  5885. itsDos    move.l    id_VolumeNode(a5),a0    ;DOS-Disk
  5886.     add.l    a0,a0
  5887.     add.l    a0,a0
  5888.     move.l    $28(a0),a0        ;name    (hope, it is NULL-ending)
  5889.     add.l    a0,a0
  5890.     add.l    a0,a0
  5891.     addq.l    #1,a0
  5892.     move.l    a0,-(sp)
  5893.     move.l    id_NumSoftErrors(a5),-(sp)    ;SoftErrors
  5894.     move.l    id_DiskState(a5),d0
  5895.     lea    statro(pc),a0
  5896.     moveq    #80,d1
  5897.     cmp.l    d1,d0
  5898.     beq.s    .H
  5899.     lea    statrw(pc),a0
  5900.     moveq    #82,d1
  5901.     cmp.l    d1,d0
  5902.     beq.s    .H
  5903.     lea    statval(pc),a0
  5904.     moveq    #81,d1
  5905.     cmp.l    d1,d0
  5906.     beq.s    .H
  5907.     lea    statun(pc),a0
  5908. .H    move.l    a0,-(sp)        ;Status
  5909.     move.l    id_BytesPerBlock(a5),d1
  5910.     move.l    d1,-(sp)        ;BlockSize
  5911.     move.l    id_NumBlocks(a5),d0
  5912.     bsr    mult_32x32
  5913.     lsr.l    #8,d0
  5914.     lsr.l    #2,d0
  5915.     move.l    d0,d2
  5916.     move.l    id_NumBlocksUsed(a5),d0
  5917.     bsr    mult_32x32
  5918.     lsr.l    #8,d0
  5919.     lsr.l    #2,d0
  5920.     move.l    d2,d3
  5921.     sub.l    d0,d3
  5922.     moveq    #100,d1
  5923.     bsr    mult_32x32
  5924.     move.l    d2,d1
  5925.     beq.s    .D
  5926.     bsr    div_32    ;%
  5927. .D    exg    d0,d2
  5928.     move.l    d3,d1
  5929.     movem.l    d0-d2,-(sp)        ;Sizes
  5930.     lea    msd_tx(pc),a0    messydos ?
  5931.     move.l    $1c(a4),d0    dn_Startup
  5932.     moveq    #2,d1
  5933.     cmp.l    d1,d0
  5934.     bls.s    .A
  5935.     lsl.l    #2,d0
  5936.     move.l    d0,a1
  5937.     move.l    8(a1),d0    fssm_Environ
  5938.     beq.s    .A
  5939.     lsl.l    #2,d0
  5940.     move.l    d0,a1
  5941.     move.l    64(a1),d0    de_DosType
  5942.     cmp.l    #"MSD"<<8,d0    CrossDos ?
  5943.     beq.s    .C
  5944. .A    move.l    id_DiskType(a5),d0
  5945.     lea    quest_tx(pc),a0
  5946.     cmp.b    #5,d0
  5947.     bhi.s    .C    unknown
  5948.     ext.w    d0
  5949.     ext.l    d0
  5950.     lea    ofs_tx(pc),a0
  5951.     lsl.l    #2,d0
  5952.     add.l    d0,a0    d0*4+a0    access table
  5953. .C    move.l    a0,-(sp)        ;System
  5954.     move.l    id_UnitNumber(a5),-(sp)    ;Unit
  5955.     move.l    a3,-(sp)        ;Name
  5956.     bsr    do_permit
  5957.     lea    (sp),a1
  5958.     lea    inform(pc),a0
  5959.     bsr    new_print
  5960.     lea    40(sp),sp
  5961.     bra    jajo
  5962.  
  5963.  
  5964.  
  5965. *****************
  5966. *    ENDCLI    *    EXIT FROM ZSHELL TO CLI.
  5967. *****************    IF WE EXIT FROM SCRIPT THEN FREE SCRIPT MEMORY
  5968. endcliz    bsr    raw_off
  5969.     move.l    parm2(a5),a0
  5970.     bsr    return_dash_option
  5971.     moveq    #-1,d7
  5972.     cmp.b    #'C',d0
  5973.     bne.s    .A
  5974.     moveq    #0,d7
  5975. .A    bsr    kill_script
  5976.     addq.l    #4,sp    kill return address on stack
  5977.     rts
  5978.  
  5979.  
  5980. ***********************************************************************
  5981. ** CHECK DIRECTORY DESCRIPTION IN (A0) AND CONVERTS INTO DIRNAME[0] AND PUTS
  5982. ** THE WILD CARD IN WILD_STRING. ALSO SETS WILD_FLAG
  5983. handle_wild_dirs
  5984.     clr.b    wild_flag(a5)
  5985.     btst    #FLwild,Flags+3(a5)
  5986.     beq.s    .B
  5987. ;    cmp.w    #37,kickver(a5)
  5988. ;    blo.s    .B
  5989.     movem.l    d2-d3/a0/a1,-(sp)
  5990.     lea    tempbuf(a5),a1
  5991.     move.l    a1,d1
  5992.     bsr    rempath
  5993.     lea    wild_string(a5),a0
  5994.     move.l    a0,d2
  5995.     moveq    #80,d3
  5996.     jsr    _LVOParsePatternNC(a6)    external matcher
  5997.     movem.l    (sp)+,d2-d3/a0/a1
  5998.     tst.l    d0
  5999.     bmi.s    .A
  6000.     beq.s    .A
  6001.     lea    tempbuf(a5),a1
  6002.     bra.s    .C
  6003. .B    lea    wild_string(a5),a1    internal matcher
  6004.     clr.b    (a1)
  6005.     bsr    check_wild
  6006.     tst.b    d0
  6007.     bne.s    .A
  6008. .C    bsr    split_wild
  6009.     move.b    #1,wild_flag(a5)
  6010. .A    rts    
  6011.  
  6012. ** CHECK STRING(A0) IF IT CONTAINS WILDCARD SPECIFIC CHARS
  6013. ** RETURN D0=0 IF WILDS FOUND
  6014. check_wild    ;only used by handle_wild_dirs
  6015.     move.l    a0,-(sp)
  6016. chk_w3    move.b    (a0)+,d0
  6017.     beq.s    chk_w2
  6018.     cmp.b    #'*',d0
  6019.     beq.s    chk_w4
  6020.     cmp.b    #'~',d0    special not char
  6021.     beq.s    chk_w4
  6022.     cmp.b    #'[',d0
  6023.     beq.s    chk_w4
  6024.     cmp.b    #']',d0
  6025.     beq.s    chk_w4
  6026.     cmp.b    #'|',d0 or char
  6027.     beq.s    chk_w4
  6028.     cmp.b    #'?',d0
  6029.     bne.s    chk_w3
  6030. chk_w4    moveq    #0,d0
  6031.     move.l    (sp)+,a0
  6032.     rts
  6033. chk_w2    moveq    #1,d0
  6034.     move.l    (sp)+,a0
  6035.     rts
  6036.  
  6037. ** SPLIT STRING(A0) INTO DIRECTORY PATH AND WILDCARD DESCRIPTION
  6038. ** NULL END THE PATH, AND MOVE THE WILDCARD TO (A1)
  6039. * eg. ram:c/*.info -> ram:c0 + *.info0    
  6040. split_wild
  6041.     movem.l    d0-d1/a0-a2,-(sp)
  6042.     move.l    a0,d1
  6043. sp_w2    move.l    a0,a2    a2=temp
  6044. sp_w3    move.b    (a0)+,d0
  6045.     beq.s    sp_w4
  6046.     cmp.b    #':',d0
  6047.     beq.s    sp_w2    A0= 1 after :
  6048.     cmp.b    #'/',d0
  6049.     beq.s    sp_w2
  6050.     bra.s    sp_w3
  6051. sp_w4    cmp.l    a2,d1
  6052.     beq.s    sp_mis
  6053.     cmp.b    #':',-1(a2)
  6054.     bne.s    sp_w5
  6055. sp_mis    move.l    a2,d1    SAVE POSITION
  6056. sp_w6    move.b    (a2)+,(a1)+
  6057.     bne.s    sp_w6
  6058.     move.l    d1,a2
  6059.     clr.b    (a2)
  6060.     movem.l    (sp)+,d0-d1/a0-a2
  6061.     rts
  6062. sp_w5    clr.b    -1(a2)
  6063. sp_w7    move.b    (a2)+,(a1)+
  6064.     bne.s    sp_w7
  6065.     movem.l    (sp)+,d0-d1/a0-a2
  6066.     rts
  6067.     
  6068. * NOTE this wildmatcher only handles cases where the wildcard has one * in it.
  6069. ** WILDCARD MATCHER. CHECK IF STRING(A0) MATCHES WILDCARD(A1)
  6070. ** RETURN D0=0 IF MATCH
  6071. ignorematch
  6072.     lea    fib_FileName(a5),a0
  6073.     lea    FNCignore(a5),a1
  6074.     tst.b    (a1)
  6075.     bne.s    wildmatch    wildcheck for names to ignore
  6076.     moveq    #1,d0
  6077.     rts
  6078.  
  6079. wildmatcher
  6080.     lea    wild_string(a5),a1
  6081. wildmatch
  6082.     btst    #FLwild,Flags+3(a5)
  6083.     beq.s    iwildmatch
  6084. ;    cmp.w    #37,kickver(a5)
  6085. ;    blo.s    iwildmatch
  6086.     movem.l    d2/a0/a1,-(sp)
  6087.     move.l    a0,d2
  6088.     move.l    a1,d1
  6089.     jsr    _LVOMatchPatternNC(a6)    external matcher
  6090.     movem.l    (sp)+,d2/a0/a1
  6091.     moveq    #0,d1
  6092.     tst.l    d0
  6093.     bne.s    .A
  6094.     addq.l    #1,d1
  6095. .A    move.l    d1,d0
  6096.     rts
  6097. iwildmatch
  6098.     movem.l    d2/a0-a3,-(sp)
  6099.     move.b    (a1),d2
  6100.     cmp.b    #"~",d2        check if all is negated
  6101.     bne.s    .C
  6102.     addq.l    #1,a1
  6103. .C    move.l    a1,a2
  6104.     move.l    a0,a3
  6105. .A    move.b    (a2)+,d0
  6106.     beq.s    .B
  6107.     cmp.b    #"|",d0        or-symbol  V2.0
  6108.     bne.s    .A
  6109.     clr.b    -1(a2)        change wildcard to end
  6110.     bsr.s    wildermatch
  6111.     move.b    #"|",-1(a2)    restore
  6112.     tst.l    d0
  6113.     beq.s    gut
  6114.     lea    (a3),a0
  6115.     lea    (a2),a1
  6116.     bra.s    .A
  6117. .B    bsr.s    wildermatch
  6118. gut    cmp.b    #"~",d2
  6119.     bne.s    .D
  6120.     subq.l    #1,d0
  6121. .D    movem.l    (sp)+,d2/a0-a3
  6122.     tst.l    d0
  6123.     rts
  6124.  
  6125. wildermatch
  6126.     cmp.b    #'~',(a1)        check for NOT specifier
  6127.     bne.s    wm_1
  6128.     move.b    (a1)+,d0
  6129.     bsr.s    wm_1
  6130.     subq.l    #1,d0    0 --> -1     1 --> 0
  6131.     rts
  6132.     
  6133. wm_1    move.b    (a0)+,d0
  6134.     beq    source_fin1
  6135.     move.b    (a1)+,d1
  6136.     cmp.b    #'*',d1
  6137.     beq.s    wild_run
  6138.     cmp.b    #'[',d1        handle character classes
  6139.     bne.s    .A
  6140. .B    move.b    (a1)+,d1
  6141.     beq.s    wild_fail
  6142.     cmp.b    #']',d1
  6143.     beq.s    wild_fail
  6144.     bsr    compD1D0nocase
  6145.     bne.s    .B
  6146. .C    move.b    (a1)+,d1
  6147.     beq.s    wild_fail
  6148.     cmp.b    #']',d1
  6149.     bne.s    .C
  6150.     bra.s    wm_1
  6151. .A    cmp.b    #'?',d1
  6152.     beq.s    wm_1
  6153.     bsr    compD1D0nocase
  6154.     beq.s    wm_1
  6155.     
  6156. wild_fail    moveq    #1,d0
  6157.     rts
  6158. wild_run    
  6159. wr_3    tst.b    (a0)+    GOTO END OF STRING
  6160.     bne.s    wr_3
  6161. wr_4    tst.b    (a1)+    GOTO END OF WILDCARD
  6162.     bne.s    wr_4
  6163. wr_5    move.b    -(a1),d0    get tail of wildcard (1st should be null)
  6164.     move.b    -(a0),d1
  6165.     cmp.b    #'*',d0
  6166.     beq.s    source_fin2
  6167.     cmp.b    #']',d0        handle class [xyz]
  6168.     bne.s    .A
  6169. .B    move.b    -(a1),d0
  6170.     cmp.b    #'*',d0
  6171.     beq.s    wild_fail
  6172.     cmp.b    #'[',d0
  6173.     beq.s    wild_fail
  6174.     bsr    compD1D0nocase
  6175.     bne.s    .B
  6176. .C    move.b    -(a1),d0
  6177.     beq.s    wild_fail    should never happen but should leave in
  6178.     cmp.b    #'[',d0
  6179.     bne.s    .C
  6180.     bra.s    wr_5
  6181. .A    cmp.b    #'?',d0
  6182.     beq.s    wr_5
  6183.     bsr    compD1D0nocase
  6184.     beq.s    wr_5
  6185.     bra.s    wild_fail
  6186. source_fin1
  6187.     tst.b    (a1)
  6188.     beq.s    source_fin2
  6189.     cmp.b    #'*',(a1)
  6190.     bne.s    wild_fail
  6191. source_fin2
  6192.     moveq    #0,d0
  6193.     rts
  6194.  
  6195. compD1D0locale
  6196.     tst.l    utilbase(a5)
  6197.     beq.s    compD1D0nocase
  6198.     movem.l    d2/a0/a1/a6,-(sp)
  6199.     move.l    utilbase(a5),a6
  6200.     move.b    d1,d2
  6201.     jsr    _LVOToUpper(a6)
  6202.     exg    d0,d2
  6203.     jsr    _LVOToUpper(a6)
  6204.     move.b    d0,d1
  6205.     move.b    d2,d0
  6206.     movem.l    (sp)+,d2/a0/a1/a6
  6207.     cmp.b    d1,d0
  6208.     rts
  6209.  
  6210. compD1D0nocase    ;lowercase d0 and d1 then compare them
  6211.     cmp.b    #'Z',d1
  6212.     bhi.s    D1_OK
  6213.     cmp.b    #'A',d1
  6214.     blo.s    D1_OK
  6215.     add.b    #$20,d1
  6216. D1_OK    cmp.b    #'Z',d0
  6217.     bhi.s    D0_OK
  6218.     cmp.b    #'A',d0
  6219.     blo.s    D0_OK
  6220.     add.b    #$20,d0
  6221. D0_OK    cmp.b    d1,d0
  6222.     rts
  6223.     
  6224. fibexnx    move.l    d7,d1
  6225.     move.l    a5,d2
  6226.     jsr    _LVOExNext(a6)
  6227.     rts
  6228.  
  6229. *********************************
  6230. *    DIRECTORY LISTER    *
  6231. *********************************
  6232. fname    equ    40    for sorting
  6233.  
  6234. * temp2(a5) bits:
  6235. DLwide        = 7    31:wide dir: DIR
  6236. DLquick        = 6    30:quick, nosort: (all)
  6237. DLverbose    = 5    29:verbose list: LIST
  6238. DLcomment    = 4    28:comment: LIST
  6239. DLfooter    = 3    27:footer: (auto)
  6240. DLdelete    = 2    26:delete file: DELETE,MOVE
  6241. DLnotproc    = 1    25:not process file: DELETE,COPY,MOVE
  6242. DLprotect    = 0    24:protect: PROTECT
  6243. DLcopy        = 7    23:copy: COPY,MOVE
  6244. DLmove        = 6    22:move: MOVE
  6245. DLrename    = 5    21:rename: MOVE
  6246. DLjoin        = 4    20:join: JOIN
  6247. DLsplit        = 3    19:split: SPLIT
  6248.  
  6249. dirz    clr.l    temp2(a5)        WIDE DIR, 2 columns
  6250.     bset    #DLwide,temp2(a5)    bit 31=wide flag
  6251.     bra.s    directory
  6252.  
  6253. listz    clr.l    temp2(a5)        NARROW DIR, clear wide flag
  6254.     bset    #DLverbose,temp2(a5)    bit 29=verbose flag
  6255.     bset    #DLcomment,temp2(a5)    bit 28=comment flag
  6256. directory        ;V2.0:many things better (sort!)
  6257.     bsr    check_q_r
  6258. directory2
  6259.     bsr    pr_hide_cursor
  6260.     lea    parm2(a5),a2
  6261.     move.l    (a2),d1
  6262.     bne.s    .A
  6263.     lea    null(pc),a0
  6264.     move.l    a0,d1
  6265.     bra.s    .B
  6266.  
  6267. .A    move.l    (a2)+,d1    list all parms
  6268.     beq.s    .C
  6269. .B    move.l    a2,-(sp)
  6270.     move.l    d1,a2
  6271.     bsr    DirLister
  6272.     move.l    (sp)+,a2
  6273.     tst.l    d0
  6274.     bne.s    .E
  6275.     tst.b    break_flag(a5)
  6276.     beq.s    .A
  6277. .C    moveq    #RETURN_OK,d0
  6278. .E    rts
  6279.  
  6280. DirLister    ;wants dirname or filename in a2
  6281.     clr.l    temp1(a5)            init total size
  6282.     and.l    #$fff80000,temp2(a5)
  6283.     clr.l    temp3(a5)
  6284.     clr.l    temp4(a5)
  6285.     bset    #DLrename,temp2+1(a5)
  6286.     btst    #DLwide,temp2(a5)
  6287.     beq.s    .A
  6288.     bset    #0,temp2+3(a5)
  6289. .A    btst    #DLquick,temp2(a5)
  6290.     beq.s    .B
  6291.     bclr    #DLcomment,temp2(a5)
  6292. .B    clr.w    indent_count(a5)
  6293.     move.l    a2,a0
  6294.     bsr    handle_wild_dirs
  6295.     lea    tempbuf(a5),a4
  6296. .C    move.b    (a2)+,(a4)+
  6297.     bne.s    .C
  6298.     bsr    pr_dir            -> print the dir
  6299.  
  6300. pr_size    movem.l    d0-d3,-(sp)        end of dirlister
  6301.     move.l    temp2(a5),d0        are we printing wide
  6302.     bpl.s    .B
  6303.     btst    #0,d0
  6304.     bne.s    .B
  6305.     bsr    pr_lf            print missing lf
  6306. .B    lea    (sp),a1
  6307.     lea    totsize(pc),a0
  6308.     btst    #DLfooter,temp2(a5)
  6309.     beq.s    .A
  6310.     bsr    new_print        print footer
  6311. .A    lea    16(sp),sp
  6312.     btst    #DLdelete,temp2(a5)        delete flag ?
  6313.     beq.s    .C
  6314.     tst.b    recurs_flag(a5)        recursiv, but no wildcard
  6315.     beq.s    .C
  6316.     tst.b    wild_flag(a5)
  6317.     bne.s    .C
  6318.     lea    tempbuf(a5),a0
  6319.     bsr    fibexam
  6320.     move.l    d7,d1
  6321.     jsr    _LVOUnLock(a6)
  6322.     bsr    SingleFile        delete parent dir
  6323. .C    moveq    #RETURN_OK,d0
  6324.     rts
  6325.  
  6326. pr_dir    bset    #DLfooter,temp2(a5)
  6327.     bclr    #DLnotproc,temp2(a5)
  6328.     lea    tempbuf(a5),a0
  6329.     bsr    fibexam
  6330.     bsr    fixsoftlink
  6331.     tst.b    recurs_flag(a5)
  6332.     bne.s    .B
  6333.     btst    #DLprotect,temp2(a5)    protect flag ?
  6334.     bne.s    .D
  6335.     btst    #DLdelete,temp2(a5)    delete flag ?
  6336.     beq.s    .B
  6337. .D    tst.b    wild_flag(a5)
  6338.     beq.s    .C
  6339. .B    tst.l    fib_DirEntryType(a5)    check entry OK
  6340.     bpl.s    prd20            print whole Directory
  6341.  
  6342. .C    bsr    check_c
  6343.     bne    unlock
  6344.     move.l    d7,d1
  6345.     jsr    _LVOUnLock(a6)        unlock file
  6346. SingleFile
  6347.     lea    tempbuf(a5),a0        process a single file/dir
  6348.     move.l    a0,a1
  6349.     tst.b    (a1)
  6350.     beq.s    .B
  6351. .A    tst.b    (a1)+
  6352.     bne.s    .A
  6353.     cmp.b    #"/",-2(a1)        make sure it does not end in /
  6354.     bne.s    .B
  6355.     clr.b    -2(a1)
  6356. .B    lea    temp2buf(a5),a1
  6357.     bsr    split_wild        separate path and filename
  6358.     lea    tempbuf(a5),a0
  6359.     move.l    a0,d1            get a lock on the dir
  6360.     moveq    #ACCESS_READ,d2
  6361.     jsr    _LVOLock(a6)
  6362.     move.l    d0,d7
  6363.     bsr    pr_it            print single file/dir
  6364.     bclr    #DLfooter,temp2(a5)    do not print footer
  6365.     bra    unlock            make sure to unlock
  6366.  
  6367. prd20    tst.w    indent_count(a5)    was a dir
  6368.     bne.s    .A
  6369.     move.l    d7,d1
  6370.     jsr    _LVOUnLock(a6)
  6371.     lea    tempbuf(a5),a0
  6372.     move.l    a0,d1
  6373.     moveq    #ACCESS_READ,d2
  6374.     jsr    _LVOLock(a6)
  6375.     lea    temp2buf(a5),a0        get full dir name for later
  6376.     clr.b    (a0)
  6377.     tst.l    d0
  6378.     beq    DOSerr
  6379.     bsr    eval_full_path
  6380.     jsr    _LVOUnLock(a6)
  6381.     lea    dirof(pc),a1
  6382.     bsr    pr_string
  6383.     lea    temp2buf(a5),a1
  6384.     bsr    pr_stringlf        print directory's name
  6385.     lea    tempbuf(a5),a0
  6386.     bsr    fibexam
  6387.  
  6388. .A    sub.l    a3,a3    ;clr a3
  6389. prd2
  6390.     bsr    check_c        CTRL-C pressed ?
  6391.     bne    unlk
  6392.     bsr    fibexnx
  6393.     tst.l    d0
  6394.     beq    unlk        ;sort ?
  6395.     bsr    fixsoftlink
  6396.     move.l    temp2(a5),d0
  6397.     btst    #31,d0
  6398.     beq.s    .C
  6399.     move.l    fib_Protection(a5),d0
  6400.     btst    #7,d0
  6401.     bne.s    prd2    hide if hide flag is set in wide dir lister
  6402. ;    lea    fib_FileName(a5),a0
  6403.     bsr    ignorematch        hide config-hide
  6404.     beq.s    prd2
  6405. .C    tst.b    wild_flag(a5)
  6406.     beq.s    dozel
  6407.     tst.b    recurs_flag(a5)
  6408.     beq.s    .A
  6409.     tst.l    fib_DirEntryType(a5)
  6410.     bpl.s    dozel
  6411. .A    lea    fib_FileName(a5),a0
  6412.     bsr    wildmatcher        check wildcards
  6413.     tst.b    d0
  6414.     bne.s    prd2
  6415. dozel    btst    #DLquick,temp2(a5)
  6416.     beq.s    collect            not quick
  6417.     btst    #DLdelete,temp2(a5)
  6418.     bne.s    collect            delete
  6419.     bsr    zelma
  6420.     bra.s    prd2
  6421.  
  6422. collect moveq    #fname,d0        collect files to sort  V2.0
  6423.     lea    fib_FileName(a5),a0
  6424.     lea    (a0),a2
  6425. .A    addq.l    #1,d0
  6426.     tst.b    (a0)+
  6427.     bne.s    .A
  6428.     lea    fib_Comment(a5),a0
  6429. .B    addq.l    #1,d0
  6430.     tst.b    (a0)+
  6431.     bne.s    .B
  6432.     bsr    iwantmem
  6433.     bsr    maybeDOSerr
  6434.     beq    unlock
  6435.     move.l    d0,a0
  6436.     move.l    a3,(a0)+
  6437.     lea    -4(a0),a3
  6438.     lea    fib_DiskKey(a5),a1    ;store fib in mem
  6439.     move.l    (a1)+,(a0)+
  6440.     move.l    (a1)+,(a0)+
  6441.     lea    fib_Protection(a5),a1
  6442.     moveq    #6,d1
  6443. .C    move.l    (a1)+,(a0)+
  6444.     dbra    d1,.C
  6445. .D    move.b    (a2)+,(a0)+    ;name
  6446.     bne.s    .D
  6447. .E    move.b    (a1)+,(a0)+    ;comment
  6448.     bne.s    .E
  6449.     bra    prd2
  6450.  
  6451. unlk    btst    #DLdelete,temp2(a5)
  6452.     bne.s    .A        delete
  6453.     btst    #DLquick,temp2(a5)
  6454.     bne    unlock        quick
  6455. .A    move.l    a3,d0    
  6456.     beq    unlock        no files
  6457. ;    tst.b    break_flag(a5)
  6458. ;    bne.s    nextfi        CTRL-C pressed
  6459.  
  6460.     movem.l    a4-a6,-(sp)
  6461.     btst    #DLquick,temp2(a5)
  6462.     bne.s    snull        quick
  6463.     move.l    utilbase(a5),d2    localized-flag and libbase
  6464.     lea    (a3),a0        ;INSERTION SORT  V2.0   (ooohuuooo)
  6465. aussort    lea    (a3),a1
  6466.     move.l    (a0),a2    ;remove (a0->) a2
  6467.     move.l    a2,d0
  6468.     beq.s    snull    ;end of list
  6469.     move.l    (a2),(a0)
  6470.     bsr    strcmp    ;compare a1 and a2
  6471.     bne.s    insort    ;insert a2 (old place)
  6472.     move.l    a2,a3    ;a2->start
  6473.     move.l    a1,(a2)    ;a1=old start
  6474.     bra.s    aussort    ;next
  6475. insort    move.l    a1,a4    ;reminder
  6476.     move.l    (a1),a1    ;next a1
  6477.     cmp.l    a0,a4
  6478.     beq.s    inold
  6479. shno    bsr    strcmp    ;compare a1 and a2
  6480.     bne.s    insort    ;go on
  6481.     move.l    a2,(a4)    ;insert a2
  6482.     move.l    a1,(a2)    ;a4->a2->a1
  6483.     bra.s    aussort
  6484. inold    move.l    (a0),(a2) ;a2 back at old place
  6485.     move.l    a2,(a0)    ;a0->a2->next
  6486.     move.l    a2,a0    ;next a0
  6487.     bra.s    aussort
  6488. snull    movem.l    (sp)+,a4-a6    ;FINISHED !!!
  6489.  
  6490.     tst.l    temp2(a5)    for normal DIR
  6491.     bpl.s    nextfi
  6492.     tst.b    recurs_flag(a5)
  6493.     bne.s    nextfi
  6494.     moveq    #1,d0        prepare for printing in 2 columns
  6495.     move.l    a3,d1
  6496. .A    addq.l    #1,d0
  6497.     move.l    d1,a0
  6498.     move.l    (a0),d1
  6499.     bne.s    .A        count number of entries (d0)
  6500.     lsr.l    #1,d0        divide by two
  6501.     move.l    a3,a2
  6502.     bra.s    .B
  6503. .C    move.l    a2,a0
  6504.     move.l    (a2),a2
  6505. .B    dbra    d0,.C        find the middle    (a2 ,precedor in a0)
  6506.     clr.l    (a0)
  6507.  
  6508. nextfi    lea    4(a3),a1    print all files
  6509.     lea    fib_DiskKey(a5),a0    ;restore fib from mem
  6510.     move.l    (a1)+,(a0)+
  6511.     move.l    (a1)+,(a0)+
  6512.     lea    fib_Protection(a5),a0
  6513.     moveq    #6,d1
  6514. .F    move.l    (a1)+,(a0)+
  6515.     dbra    d1,.F
  6516.     moveq    #fname,d0
  6517.     lea    fib_FileName(a5),a0
  6518. .H    addq.l    #1,d0
  6519.     move.b    (a1)+,(a0)+    ;name
  6520.     bne.s    .H
  6521.     lea    fib_Comment(a5),a0
  6522. .B    addq.l    #1,d0
  6523.     move.b    (a1)+,(a0)+    ;comment
  6524.     bne.s    .B
  6525.     movem.l    d0/a2/a3,-(sp)
  6526.     tst.b    break_flag(a5)
  6527.     bne.s    .C        CTRL-C pressed
  6528.     bsr    check_c
  6529.     bne.s    .C
  6530.     bsr    zelma
  6531. .C    movem.l    (sp)+,d0/a2/a3
  6532.     move.l    (a3),d2
  6533.     lea    (a3),a1
  6534.     bsr    givemem
  6535.     move.l    d2,a3
  6536.     tst.l    temp2(a5)
  6537.     bpl.s    .A
  6538.     tst.b    recurs_flag(a5)
  6539.     bne.s    .A
  6540.     move.l    a2,a0        swap lower and upper list
  6541.     move.l    a3,a2
  6542.     move.l    a0,a3
  6543. .A    move.l    a3,d0        tst.l    a3
  6544.     bne    nextfi
  6545.  
  6546. unlock    move.l    d7,d1
  6547.     jsr    _LVOUnLock(a6)
  6548.     move.l    temp1(a5),d0    ;total size
  6549.     move.l    temp4(a5),d1
  6550.     move.l    temp2(a5),d2    ;No. of files and dirs
  6551.     btst    #31,d2
  6552.     beq.s    .A
  6553.     subq.l    #1,d2
  6554. .A    and.l    #$0007ffff,d2    ;1.000.000 files max. should be enough
  6555.     move.l    temp3(a5),d3    ;No. of dirs
  6556.     sub.l    d3,d2
  6557.     rts
  6558.  
  6559. strcmp    move.l    8(a1),d0
  6560.     move.l    8(a2),d1
  6561.     bmi.s    .A
  6562.     tst.l    d0    a2 is dir
  6563.     bpl.s    .B    a1 is dir too
  6564.     bra.s    donoth    a2:dir    a1:file
  6565. .A    tst.l    d0    a2 is file
  6566.     bpl.s    inseit    a2:file    a1:dir
  6567. .B    lea    fname(a1),a5    a1 is file too
  6568.     lea    fname(a2),a6
  6569. stcmp    tst.l    d2
  6570.     bne.s    lstcmp
  6571.     move.b    (a5)+,d1    compare strings in a3 and a4
  6572.     beq.s    donoth
  6573.     move.b    (a6)+,d0
  6574.     beq.s    inseit
  6575.     bsr    compD1D0nocase
  6576.     beq.s    stcmp
  6577.     bhi.s    donoth
  6578. inseit    moveq    #0,d0        insert it !
  6579.     rts
  6580. donoth    moveq    #1,d0        do nothing !
  6581.     rts
  6582.  
  6583. lstcmp    movem.l    a0/a1/a6,-(sp)    localized string-compare
  6584.     move.l    a5,a0
  6585.     move.l    a6,a1
  6586.     move.l    d2,a6
  6587.     jsr    _LVOStricmp(a6)
  6588.     tst.l    d0
  6589.     bmi.s    .A
  6590.     moveq    #0,d0
  6591. .A    movem.l    (sp)+,a0/a1/a6
  6592.     rts
  6593.  
  6594. zelma    tst.l    fib_DirEntryType(a5)
  6595.     bpl.s    .C
  6596.     bsr    pr_it        print file
  6597.     rts
  6598. .C    tst.b    recurs_flag(a5)
  6599.     bne.s    .B
  6600.     bsr    pr_it        print dir
  6601. .A    rts
  6602. .B    bset    #DLnotproc,temp2(a5)    do not process this dir
  6603.     bsr    pr_it        print dir recursive
  6604.     bclr    #DLnotproc,temp2(a5)
  6605.     move.w    temp2(a5),d0
  6606.     and.w    #%0000010010010000,d0    copy,delete or join flag
  6607.     beq.s    .D        no
  6608.     btst    #DLcopy,temp2+1(a5)    copy ?
  6609.     beq.s    .E
  6610.     move.l    temp5(a5),d1    yes:create new dir
  6611.     bsr    CurrentDir
  6612.     move.l    d0,d3
  6613.     lea    fib_FileName(a5),a2    copy: create dir
  6614.     move.l    a2,d1
  6615.     jsr    _LVOCreateDir(a6)
  6616.     move.l    d0,d2
  6617.     bne.s    .F
  6618. .G    jsr    _LVOIoErr(a6)
  6619.     cmp.l    #203,d0
  6620.     beq.s    .H
  6621.     move.l    d0,d2
  6622.     bsr    pr_lf
  6623.     move.l    d3,d1
  6624.     bsr    CurrentDir
  6625.     move.l    d2,d0
  6626.     bsr    pr_DOSerr
  6627.     rts
  6628. .F    move.l    d2,d1        unlock new dir, because is exclusive
  6629.     jsr    _LVOUnLock(a6)
  6630. .H    move.l    a2,d1
  6631.     moveq    #ACCESS_READ,d2
  6632.     jsr    _LVOLock(a6)
  6633.     move.l    d0,d2
  6634.     beq.s    .G
  6635.     move.l    d3,d1
  6636.     bsr    CurrentDir
  6637.     move.l    temp5(a5),d1    unlock old in temp5
  6638.     jsr    _LVOUnLock(a6)
  6639.     move.l    d2,temp5(a5)
  6640.     lea    makedirOK(pc),a1
  6641.     bsr    pr_string
  6642.     bsr    AdjustPath
  6643.     bra.s    .D
  6644. .E    bsr    pr_lf        no copy: just print lf
  6645.  
  6646. .D    moveq    #120,d0    ;(24bytes per recurs + subs + move-path)
  6647.     bsr    stacktest
  6648.     bne    .A
  6649.     move.l    fib_DiskKey(a5),d0
  6650.     movem.l    d0/d7/a4,-(sp)
  6651.     lea    fib_FileName(a5),a0
  6652.     subq.l    #1,a4
  6653.     lea    tempbuf(a5),a1
  6654.     cmp.l    a1,a4
  6655.     beq.s    jo
  6656.     cmp.b    #":",-1(a4)
  6657.     beq.s    jo
  6658.     cmp.b    #"/",-1(a4)
  6659.     beq.s    jo
  6660.     move.b    #"/",(a4)+
  6661. jo    move.b    (a0)+,(a4)+        ;addpath
  6662.     bne.s    jo
  6663.     addq.w    #2,indent_count(a5)
  6664. jojo    bsr    pr_dir            RECURSION    V2.0
  6665.     subq.w    #2,indent_count(a5)
  6666.     movem.l    (sp)+,d0/d7/a4
  6667.     move.l    d0,fib_DiskKey(a5)    ;restore fib
  6668.     lea    -1(a4),a0
  6669.     cmp.b    #"/",(a0)
  6670.     bne.s    .D
  6671.     clr.b    (a0)
  6672.     addq.l    #1,a0
  6673. .D    lea    (a0),a2
  6674.     lea    fib_FileName(a5),a1
  6675. je    move.b    (a0)+,(a1)+
  6676.     bne.s    je
  6677.     clr.b    (a2)
  6678.     moveq    #2,d0
  6679.     move.l    d0,fib_DirEntryType(a5)
  6680.     move.l    d0,fib_EntryType(a5)
  6681.     moveq    #0,d0
  6682.     move.l    d0,fib_Size(a5)
  6683.     move.l    d0,fib_NumBlocks(a5)
  6684.     btst    #DLcopy,temp2+1(a5)    copy ?
  6685.     beq.s    .B
  6686.     move.l    temp5(a5),d2    COPY
  6687.     move.l    d2,d1
  6688.     jsr    _LVOParentDir(a6)
  6689.     move.l    d0,temp5(a5)
  6690.     move.l    d2,d1
  6691.     jsr    _LVOUnLock(a6)
  6692.     bsr    AdjustPath
  6693. .B    btst    #DLdelete,temp2(a5)    delete ?
  6694.     beq.s    .A
  6695.     move.l    temp2(a5),-(sp)
  6696.     bclr    #DLmove,temp2+1(a5)    move off
  6697.     bsr    pr_it        now delete this dir
  6698.     move.l    (sp)+,temp2(a5)
  6699. .A    rts
  6700.  
  6701. AdjustPath
  6702.     btst    #DLmove,temp2+1(a5)
  6703.     beq.s    .D
  6704.     btst    #DLrename,temp2+1(a5)
  6705.     beq.s    .D
  6706.     move.l    temp5(a5),d1
  6707.     jsr    _LVODupLock(a6)
  6708.     tst.l    d0
  6709.     beq    DOSerr
  6710.     move.l    temp7(a5),a0
  6711.     bsr    eval_full_path
  6712.     jsr    _LVOUnLock(a6)
  6713. .D    rts
  6714.  
  6715. pr_it    bsr    num_spc            print file or dir
  6716.     tst.l    fib_DirEntryType(a5)    check whether is dir
  6717.     bmi.s    .A            if plus,is directory
  6718.     move.l    temp2(a5),d0        check for "DIR -R"
  6719.     bpl.s    .G
  6720.     tst.b    recurs_flag(a5)
  6721.     beq.s    .G
  6722.     btst    #0,d0
  6723.     bne.s    .H
  6724.     subq.l    #1,temp2(a5)
  6725.     bsr    pr_lf            for DIR -R directories
  6726. .H    addq.l    #1,temp2(a5)
  6727. .G    lea    farb3(pc),a1        change foregnd colour
  6728.     bsr    addstring
  6729.     addq.l    #1,temp3(a5)        one dir more
  6730. .A    lea    fib_FileName(a5),a1
  6731.     move.l    a1,a0
  6732.     moveq    #-1,d2
  6733.     add.w    indent_count(a5),d2
  6734. .B    addq    #1,d2
  6735.     tst.b    (a0)+
  6736.     bne.s    .B
  6737.     bsr     addstring        print filename
  6738.  
  6739.     tst.l    fib_DirEntryType(a5)
  6740.     bpl.s    .C
  6741. .F    move.l    fib_NumBlocks(a5),d0
  6742.     add.l    d0,temp4(a5)
  6743.     move.l    fib_Size(a5),d0
  6744.     add.l    d0,temp1(a5)        increase total size
  6745.     move.b    #" ",(a2)+
  6746.     moveq    #34,d1
  6747.     sub.w    d2,d1
  6748.     bsr    qdecpr
  6749.     bra.s    prlink
  6750. .C    moveq    #29,d1
  6751.     sub.w    d2,d1
  6752.     bpl.s    .D
  6753.     moveq    #0,d1
  6754. .D    move.b    #" ",(a2)+
  6755.     dbra    d1,.D
  6756.     lea    dirtext(pc),a1
  6757.     bsr    addstring
  6758. prlink    move.b    #" ",(a2)+
  6759.     move.b    #" ",(a2)+
  6760.     move.l    fib_DirEntryType(a5),d0
  6761.     moveq    #-6,d1
  6762.     cmp.l    d1,d0
  6763.     bne.s    .B
  6764.     move.b    #"S",-1(a2)
  6765.     bra.s    .A
  6766. .B    moveq    #4,d1
  6767.     cmp.l    d1,d0
  6768.     bne.s    .C
  6769.     move.b    #"H",-1(a2)
  6770.     bra.s    .A
  6771. .C    moveq    #-4,d1
  6772.     cmp.l    d1,d0
  6773.     bne.s    .A
  6774.     move.b    #"H",-1(a2)
  6775. .A    move.b    #" ",(a2)+
  6776.     addq.l    #1,temp2(a5)
  6777.     move.l    temp2(a5),d0        are we printing wide
  6778.     bpl.s    wpro
  6779.     btst    #0,d0
  6780.     beq.s    .F
  6781.     move.b    #LF,(a2)+
  6782. .F    clr.b    (a2)
  6783.     lea    temp2buf(a5),a1
  6784.     bra    pr_string        print string&return and return
  6785.  
  6786. wpro    btst    #DLverbose,temp2(a5)
  6787.     beq.s    .E
  6788.     move.l    a2,a0
  6789.     bsr    pr_pro2            print protection V2.0
  6790.     move.b    #" ",(a0)+
  6791.     move.l    a0,a2            (goes to temp2buf)
  6792.     btst    #DLprotect,temp2(a5)    protect flag ?
  6793.     bne.s    .E
  6794.     lea    fib_Date(a5),a1
  6795.     bsr    insert_date
  6796.     move.b    #LF,(a2)+
  6797. .E    clr.b    (a2)
  6798.     lea    temp2buf(a5),a1
  6799.     bsr    pr_string        print date/time V2.0
  6800.  
  6801.     move.l    d7,d1
  6802.     bsr    CurrentDir        d0=old current dir
  6803.     movem.l    d0/d4-d7/a3-a4,-(sp)
  6804.     move.l    d7,d6
  6805.     btst    #DLcomment,temp2(a5)
  6806.     beq    fort
  6807.     tst.b    fib_Comment(a5)
  6808.     beq.s    .A
  6809.     bsr    num_spc
  6810.     lea    farb2(pc),a1
  6811.     bsr    addstring
  6812.     move.b    #":",(a2)+
  6813.     clr.b    (a2)
  6814.     lea    temp2buf(a5),a1
  6815.     bsr    pr_string
  6816.     lea    fib_Comment(a5),a1
  6817.     bsr    pr_string        print Comment V2.0
  6818.     lea    farb1(pc),a1
  6819.     bsr    pr_stringlf
  6820.  
  6821. .A    cmp.w    #36,kickver(a5)
  6822.     blo    fort
  6823.     move.l    fib_DirEntryType(a5),d0
  6824.     bpl.s    .F
  6825.     neg.l    d0
  6826. .F    moveq    #4,d1
  6827.     cmp.l    d0,d1
  6828.     bne.s    .G
  6829.     lea    NewPrintBuffer(a5),a2    process hardlinks
  6830.     lea    farb2(pc),a1
  6831.     bsr    addstring
  6832.     lea    pfeil(pc),a1
  6833.     bsr    addstring
  6834.     lea    fib_FileName(a5),a0
  6835.     move.l    a0,d1
  6836.     moveq    #ACCESS_READ,d2
  6837.     jsr    _LVOLock(a6)
  6838.     tst.l    d0
  6839.     beq.s    .C
  6840.     move.l    a2,a0
  6841.     bsr    eval_full_path
  6842.     jsr    _LVOUnLock(a6)
  6843.     bra.s    .B
  6844. .G    moveq    #-6,d0
  6845.     cmp.l    fib_DirEntryType(a5),d0    check whether is softlink
  6846.     bne.s    fort
  6847.     lea    fib_FileName(a5),a2    process softlinks
  6848.     move.l    a2,d1
  6849.     jsr    _LVODeviceProc(a6)
  6850.     move.l    d0,d4
  6851.     beq.s    .C
  6852.     move.l    a2,d3    path (filename)
  6853.     lea    NewPrintBuffer(a5),a2
  6854.     lea    farb2(pc),a1
  6855.     bsr    addstring
  6856.     lea    pfeil(pc),a1
  6857.     bsr    addstring
  6858.     move.l    d4,d1    msgport of device
  6859.     move.l    d6,d2    lock on current dir
  6860.     move.l    a2,d4    buffer
  6861.     moveq    #120,d5    size of buffer
  6862.     jsr    _LVOReadLink(a6)
  6863. .C    bsr    maybeDOSerr
  6864.     beq.s    fort
  6865. .B    lea    NewPrintBuffer(a5),a1
  6866.     bsr    pr_string        ;print softlink V2.3
  6867.     lea    farb1(pc),a1
  6868.     bsr    pr_stringlf
  6869.  
  6870. fort    move.w    temp2(a5),d0    get upper two bytes
  6871.     and.w    #%0000010010010000,d0    copy,delete or join flag
  6872.     beq    .B        no: try protect
  6873.     btst    #DLnotproc,temp2(a5)
  6874.     bne    .A        not process flag ?
  6875.  
  6876.     btst    #DLmove,temp2+1(a5)    move flag ?
  6877.     beq.s    .E
  6878.     btst    #DLrename,temp2+1(a5)    MOVE !
  6879.     beq.s    .E    need not try to rename
  6880.     tst.l    fib_DirEntryType(a5)
  6881.     bpl.s    .D    delete dir
  6882.     lea    fib_FileName(a5),a0
  6883.     bsr    MoveFile
  6884.     bne    .A
  6885.     bclr    #DLrename,temp2+1(a5)    cannot rename
  6886.  
  6887. .E    btst    #DLcopy,temp2+1(a5)        copy flag ?
  6888.     beq.s    .D
  6889.     tst.l    fib_DirEntryType(a5)
  6890.     bpl    .H
  6891.     lea    fib_FileName(a5),a0    COPY !
  6892.     bsr    CopyFileToDir
  6893.     bne    .A        error occured->not delete
  6894.  
  6895. .D    btst    #DLdelete,temp2(a5)    delete flag ?
  6896.     beq.s    .C
  6897.     lea    fib_FileName(a5),a0    DELETE !
  6898.     tst.l    fib_DirEntryType(a5)
  6899.     bpl.s    .I    
  6900.     bsr    DoDelete
  6901.     bra.s    .C
  6902. .I    bsr    DoDelete2
  6903.  
  6904. .C    btst    #DLjoin,temp2+1(a5)    join flag ?
  6905.     beq.s    .B
  6906.     tst.l    fib_DirEntryType(a5)
  6907.     bpl.s    .H
  6908.     lea    fib_FileName(a5),a0    JOIN !
  6909.     bsr    JoinFile
  6910.  
  6911. .B    btst    #DLprotect,temp2(a5)    protect flag ?
  6912.     beq.s    .A
  6913.     tst.b    recurs_flag(a5)        PROTECT !
  6914.     beq.s    .F
  6915.     tst.l    fib_DirEntryType(a5)    no recursive dir protects
  6916.     bpl.s    .H
  6917. .F    move.l    fib_Protection(a5),d2
  6918.     move.l    d2,d0
  6919.     eor.b    #$0f,d2
  6920.     and.l    temp6(a5),d2
  6921.     or.l    temp5(a5),d2
  6922.     eor.b    #$0f,d2
  6923.     cmp.l    d2,d0
  6924.     beq.s    .H
  6925.     move.l    d2,fib_Protection(a5)
  6926.     lea    fib_FileName(a5),a0
  6927.     move.l    a0,d1
  6928.     jsr    _LVOSetProtection(a6)
  6929.     bsr    maybeDOSerr
  6930.     lea    temp2buf(a5),a2    print new protection
  6931.     lea    pfeil(pc),a1
  6932.     bsr    addstring
  6933.     move.l    a2,a0
  6934.     bsr    pr_pro2
  6935.     move.b    #LF,(a0)+
  6936.     clr.b    (a0)
  6937.     bsr    pr_string    (temp2buf in a1)
  6938.  
  6939.     bra.s    .A
  6940. .H    bsr    pr_lf
  6941. .A    movem.l    (sp)+,d0/d4-d7/a3-a4
  6942.     move.l    d0,d1
  6943.     bsr    CurrentDir
  6944.     rts
  6945.  
  6946. insert_date    ;a1 points to datestamp, string goes to a2
  6947.     lea    -14(sp),sp
  6948.     lea    (sp),a0
  6949.     bsr    convert_time
  6950.     move.l    a2,a1
  6951.     bsr    qprint10
  6952.     move.b    #".",(a1)+
  6953.     bsr    qprint10
  6954.     move.b    #".",(a1)+
  6955.     bsr    qprint10
  6956.     move.b    #" ",(a1)+
  6957.     move.b    #" ",(a1)+
  6958.     bsr    qprint10
  6959.     move.b    #":",(a1)+
  6960.     bsr    qprint10
  6961.     move.b    #":",(a1)+
  6962.     bsr    qprint10
  6963.     lea    14(sp),sp
  6964.     move.l    a1,a2
  6965.     rts
  6966.  
  6967. qprint10 move.w    (a0)+,d0    V2.0
  6968. qpr10    ext.l    d0    (also used by More, GuruIt and Pipe)
  6969.     divu    #10,d0    Value in d0 , Buffer in a1
  6970.     add.b    #"0",d0
  6971.     move.b    d0,(a1)+
  6972.     swap    d0
  6973.     add.b    #"0",d0
  6974.     move.b    d0,(a1)+
  6975.     rts
  6976.  
  6977. num_spc    lea    temp2buf(a5),a2        V2.0
  6978.     move.w    indent_count(a5),d0
  6979.     moveq    #$3f,d1
  6980.     and.l    d1,d0
  6981.     bra.s    .B
  6982. .A    move.b    #" ",(a2)+    the preceding spaces
  6983. .B    dbra    d0,.A
  6984.     rts
  6985.  
  6986. addstring    move.b (a1)+,(a2)+
  6987.     bne.s    addstring
  6988.     subq.l    #1,a2
  6989.     rts
  6990.  
  6991. qdecpr    * Number in d0.l , Length in d1.w , adds string to buffer in a2
  6992.     movem.l    d2/d3/a0,-(sp)    ;Prints Decimal Number in (a2)
  6993.     lea    -12(sp),sp
  6994.     move.l    sp,a0
  6995.     move.l    d1,d3
  6996.     moveq    #0,d2
  6997. .A    moveq    #LF,d1
  6998.     bsr    div_32
  6999.     add.b    #$30,d1
  7000.     move.b    d1,(a0)+
  7001.     addq.w    #1,d2
  7002.     tst.l    d0
  7003.     bne.s    .A
  7004.     sub.w    d2,d3
  7005.     subq.w    #1,d3
  7006.     bmi.s    .B
  7007. .D    move.b    #" ",(a2)+
  7008.     dbra    d3,.D
  7009. .B    subq.w    #1,d2
  7010. .C    move.b    -(a0),(a2)+
  7011.     dbra    d2,.C
  7012.     lea    12(sp),sp
  7013.     movem.l    (sp)+,d2/d3/a0
  7014.     rts
  7015.  
  7016. fixsoftlink
  7017.     moveq    #3,d0
  7018.     cmp.l    fib_DirEntryType(a5),d0        is it a softlink ?
  7019.     bne.s    .A
  7020.     move.l    #-6,fib_DirEntryType(a5)    make it look like a file
  7021. .A    rts
  7022.  
  7023. *** CHECK CTRL_C
  7024. ** RETURN NE if ctrl c, EQ if not
  7025. check_c    movem.l    d0-d1/a0-a1/a6,-(sp)    checks if CTRL-C pressed
  7026.     tst.b    break_flag(a5)
  7027.     bne.s    .A
  7028.     moveq    #0,d0
  7029.     moveq    #0,d1
  7030.     move.l    4.w,a6
  7031.     bset    #SIGBREAKB_CTRL_C,d1
  7032.     jsr    _LVOSetSignal(a6)
  7033.     btst    #SIGBREAKB_CTRL_C,d0
  7034.     beq.s    .B
  7035. .A    move.l    dosbase(a5),a6
  7036.     move.l    #304,d0
  7037.     bsr    pr_DOSerr
  7038.     move.b    #1,break_flag(a5)    NE: STOP!!!
  7039.     movem.l    (sp)+,d0-d1/a0-a1/a6
  7040.     rts
  7041. .B    clr.b    break_flag(a5)
  7042.     moveq    #0,d0            EQ: no stop
  7043.     movem.l    (sp)+,d0-d1/a0-a1/a6
  7044.     rts
  7045.  
  7046.  
  7047. *REMOVE PATH A0-> source A1->destination
  7048. rempath    movem.l d0/a0-a2,-(sp)
  7049. rempath1    move.l a0,a2
  7050. rempath2    move.b (a0)+,d0
  7051.     cmp.b #'/',d0
  7052.     beq.s rempath1
  7053.     cmp.b #':',d0
  7054.     beq.s rempath1
  7055.     tst.b d0
  7056.     bne.s rempath2
  7057.     move.l a2,a0
  7058.     bsr cp_string
  7059.     movem.l (sp)+,d0/a0-a2
  7060.     rts
  7061.  
  7062.  
  7063. ** PRINT STRING (A1) USING indent_count(a5) AS A SPACE INDENT COUNT
  7064. prindent    movem.l    d7/a0-a1,-(sp)
  7065.     move.w    indent_count(a5),d7
  7066.     move.l    a1,a0
  7067.     and.w    #$3f,d7
  7068.     beq.s    .A
  7069.     bra.s    .B
  7070. .C    bsr    pr_space    print d7 spaces
  7071. .B    dbra    d7,.C
  7072.     move.l    a0,a1
  7073. .A    bsr    pr_string
  7074.     movem.l    (sp)+,d7/a0-a1
  7075.     rts
  7076.  
  7077. ** ENTRY A0 pts to parameter.
  7078. ** EXIT D0=lower case char after dash OR 0 if no dash command.
  7079. return_dash_option
  7080.     moveq    #0,d0
  7081.     cmp.b    #$22,-1(a0)    enclosed in quotes ?
  7082.     beq.s    .B
  7083.     cmp.b    #'-',(a0)    options start with a dash
  7084.     bne.s    .B
  7085.     tst.b    2(a0)        max. 1 char each option
  7086.     bne.s    .B
  7087. .A    move.b    1(a0),d0
  7088.     cmp.b    #'a',d0
  7089.     blo.s    .B
  7090.     cmp.b    #'z',d0
  7091.     bhi.s    .B
  7092.     sub.b    #$20,d0
  7093. .B    rts
  7094.  
  7095. check_q_r    ;checks for -q, -s or -r (or ALL) options, parm-ptr in a2
  7096.     lea    parm2(a5),a2
  7097.     clr.b    recurs_flag(a5)
  7098.     btst    #FLall,Flags+3(a5)
  7099.     beq.s    .A
  7100.     lea    alltx(pc),a0
  7101.     bsr    LookForOpt
  7102.     bne.s    .A
  7103.     move.b    #1,recurs_flag(a5)
  7104. .A    move.l    a2,a1
  7105.     move.l    (a1),d0
  7106.     beq.s    .E
  7107.     move.l    d0,a0
  7108.     bsr    return_dash_option
  7109.     tst.l    d0
  7110.     beq.s    .E
  7111.     cmp.b    #"R",d0
  7112.     bne.s    .B
  7113.     move.b    #1,recurs_flag(a5)    -r -> recursive
  7114.     bra.s    .G
  7115. .B    cmp.b    #"Q",d0
  7116.     bne.s    .C
  7117.     bset    #DLquick,temp2(a5)        -q -> quick,nosort
  7118.     bra.s    .G
  7119. .C    cmp.b    #"S",d0
  7120.     bne.s    .E
  7121.     bclr    #DLquick,temp2(a5)        -s -> noquick,sort
  7122. .G    lea    4(a1),a0
  7123. .F    move.l    (a0)+,(a1)+
  7124.     bne.s    .F
  7125.     bra.s    .A
  7126. .E    rts
  7127.  
  7128.  
  7129. CurrentDir    ;same as _LVOCurrentDir(a6)
  7130.     move.l    thistask(a5),a0
  7131.     lea    pr_CurrentDir(a0),a0
  7132.     move.l    (a0),d0
  7133.     move.l    d1,(a0)
  7134.     rts
  7135.  
  7136. *************************
  7137. *    DELETE        *    V2.3 new written
  7138. *************************
  7139. deletez    clr.l    temp2(a5)
  7140.     bset    #DLdelete,temp2(a5)
  7141.     bsr    check_q_r
  7142.     move.l    (a2),d0
  7143.     beq    too_less_args
  7144.     move.l    d0,a0
  7145.     lea    devicetx(pc),a1
  7146.     bsr    CheckOpt
  7147.     beq    deldevice    format device quick
  7148.     lea    forcetx(pc),a0
  7149.     bsr    LookForOpt    FORCE-flag ?
  7150.     subq.l    #1,d0
  7151.     move.l    d0,temp5(a5)
  7152.     bra    directory2    delete as many files as given
  7153.  
  7154. DoDelete    ;file to delete in a0
  7155.     bsr    AskYesNo    ASK first
  7156.     bne.s    DoDeEnd
  7157. DoDelete2
  7158.     move.l    a0,a2
  7159. .E    move.l    a2,d1
  7160.     jsr    _LVODeleteFile(a6)    delete file/dir
  7161.     tst.l    d0
  7162.     bne.s    .B
  7163. .D    jsr    _LVOIoErr(a6)
  7164.     cmp.l    #222,d0        delete-protected ?
  7165.     bne.s    .A
  7166.     tst.l    temp5(a5)    FORCE-flag ?
  7167.     beq.s    .A
  7168.     move.l    a2,d1
  7169.     moveq    #0,d2
  7170.     jsr    _LVOSetProtection(a6)
  7171.     tst.l    d0
  7172.     beq.s    .D
  7173.     bra.s    .E        try again
  7174. .A    btst    #DLmove,temp2+1(a5)
  7175.     bne.s    .F        move: do not print lf
  7176.     bsr    pr_lf            error occured
  7177. .F    bsr    pr_DOSerr
  7178.     bra.s    DoDeEnd
  7179. .B    lea    deleteOK(pc),a1    delete successful
  7180.     btst    #DLmove,temp2+1(a5)
  7181.     bne.s    DoDeEnd        move: do not print
  7182.     bsr    pr_string
  7183. DoDeEnd    rts
  7184.  
  7185.  
  7186. AskYesNo
  7187.     movem.l    d1-d3/a0-a2,-(sp)
  7188.     btst    #DLquick,temp2(a5)    quick flag set
  7189.     bne.s    .B
  7190.     btst    #DLmove,temp2+1(a5)    move-> do not ask
  7191.     bne.s    .B
  7192.     move.l    stdin(a5),d1
  7193.     beq.s    .B
  7194.     bsr    raw_on
  7195.     bsr    pr_show_cursor
  7196.     lea    yesnotx(pc),a1
  7197.     bsr    pr_string
  7198.     lea    temp2buf(a5),a2
  7199.     clr.b    (a2)
  7200.     move.l    a2,d2
  7201.     moveq    #20,d3    read only 1 char
  7202.     jsr    _LVORead(a6)
  7203.     clr.b    1(a2)
  7204.     cmp.b    #13,(a2)
  7205.     bne.s    .F
  7206.     move.b    #"Y",(a2)
  7207. .F    bclr    #5,(a2)
  7208.     move.l    a2,a1
  7209.     bsr    pr_string    show it
  7210.     bsr    pr_space
  7211.     bsr    pr_hide_cursor
  7212.     bsr    raw_off
  7213.     cmp.b    #"Y",(a2)    yes ?
  7214.     beq.s    .B
  7215.     cmp.b    #"A",(a2)    all ?
  7216.     bne.s    .A
  7217.     bset    #DLquick,temp2(a5)    set quick flag
  7218.     bra.s    .B
  7219. .A    cmp.b    #"Q",(a2)    quit ?
  7220.     bne.s    .E
  7221.     move.b    #1,break_flag(a5)
  7222. .E    bsr    pr_lf
  7223. .C    moveq    #-1,d0        NO end
  7224.     bra.s    .D
  7225. .B    moveq    #0,d0        YES end
  7226. .D    movem.l    (sp)+,d1-d3/a0-a2
  7227.     rts
  7228.  
  7229. *************************
  7230. deldevice        ;formats device quick    V2.3
  7231.     bsr    CheckKS
  7232.     move.l    parm3(a5),d1
  7233.     beq    too_less_args
  7234.     move.l    d1,a2
  7235.     moveq    #-2,d2
  7236.     jsr    _LVOLock(a6)    lock on drive
  7237.     move.l    d0,d7
  7238.     beq    DOSerr
  7239.     move.l    d0,d1
  7240.     move.l    a5,d2        get info data into fib
  7241.     jsr    _LVOInfo(a6)
  7242.     tst.l    d0
  7243.     beq    DOSerrUL
  7244.     move.l    d7,d1
  7245.     jsr    _LVOUnLock(a6)
  7246.     lea    formatask(pc),a1
  7247.     bsr    pr_string
  7248.     bsr    rask
  7249.     tst.l    d0
  7250.     beq.s    .A
  7251.     move.l    parm4(a5),d4
  7252.     bne.s    .B
  7253.     move.l    id_VolumeNode(a5),a0
  7254.     add.l    a0,a0
  7255.     add.l    a0,a0
  7256.     move.l    $28(a0),a1    volumename
  7257.     add.l    a1,a1
  7258.     add.l    a1,a1
  7259.     lea    temp2buf(a5),a4
  7260.     move.l    a4,d4
  7261.     bsr    copy_bstr
  7262.     clr.b    (a4)
  7263. .B    move.l    parm5(a5),d0    check for filesystem
  7264.     beq.s    .D
  7265.     lea    ofs_tx(pc),a1
  7266.     move.l    d0,a0
  7267.     moveq    #0,d3
  7268. .E    bsr    CheckOpt
  7269.     bne.s    .F
  7270.     add.l    #"DOS"<<8,d3
  7271.     bra.s    .G
  7272. .F    addq.b    #1,d3
  7273.     cmp.b    #6,d3
  7274.     bne.s    .E
  7275. .D    move.l    id_DiskType(a5),d3    dostype
  7276. .G    move.l    a2,d1
  7277.     moveq    #-1,d2
  7278.     jsr    _LVOInhibit(a6)        disable drive
  7279.     tst.l    d0
  7280.     beq    DOSerr
  7281.     move.l    a2,d1
  7282.     move.l    d4,d2
  7283.     jsr    _LVOFormat(a6)        format it quick !
  7284.     bsr    maybeDOSerr
  7285.     move.l    a2,d1
  7286.     moveq    #0,d2
  7287.     jsr    _LVOInhibit(a6)        enable drive
  7288.     tst.l    d0
  7289.     beq    DOSerr
  7290. .A    moveq    #RETURN_OK,d0
  7291.     rts
  7292.  
  7293. *************************
  7294. *    PROTECT        *    V2.3 new written
  7295. *************************
  7296. protectz
  7297.     clr.l    temp2(a5)
  7298.     bset    #DLverbose,temp2(a5)    bit 29=verbose flag
  7299.     bset    #DLprotect,temp2(a5)    bit 24=protect flag
  7300.     bset    #DLquick,temp2(a5)    bit 30=quick flag
  7301.     bsr    check_q_r
  7302.     tst.l    (a2)+
  7303.     beq    too_less_args
  7304.     clr.l    temp5(a5)
  7305.     clr.l    temp6(a5)
  7306. .A    move.l    (a2)+,d0
  7307.     beq.s    .D
  7308.     move.l    d0,a0
  7309.     cmp.b    #"+",(a0)    look for add-option
  7310.     bne.s    .B
  7311.     bsr    GetProtMask
  7312.     or.l    d0,temp5(a5)
  7313.     bra.s    .C
  7314. .B    cmp.b    #"-",(a0)    look for sub-option
  7315.     bne.s    .F
  7316.     bsr    GetProtMask
  7317.     or.l    d0,temp6(a5)
  7318.     bra.s    .C
  7319. .F    cmp.b    #"=",(a0)    look for equal-option
  7320.     bne.s    .A
  7321.     bsr    GetProtMask
  7322.     move.l    d0,temp5(a5)
  7323.     moveq    #-1,d0
  7324.     move.l    d0,temp6(a5)
  7325. .C    move.l    a2,a0
  7326.     lea    -4(a2),a1
  7327. .E    move.l    (a0)+,(a1)+    delete this parm
  7328.     bne.s    .E
  7329.     subq.l    #4,a2
  7330.     bra.s    .A
  7331.  
  7332. .D    moveq    #-1,d0
  7333.     eor.l    d0,temp6(a5)
  7334.     bra    directory2    jump into dir-lister
  7335.  
  7336.  
  7337. GetProtMask    ;a0=bits-string, d0=bit-mask
  7338.     moveq    #0,d0
  7339.     addq.l    #1,a0
  7340. .B    move.b    (a0)+,d1
  7341.     beq.s    .C
  7342.     moveq    #7,d2
  7343. .A    cmp.b    protflags(pc,d2.w),d1
  7344.     bne.s    .D
  7345.     bset    d2,d0
  7346.     bra.s    .B
  7347. .D    dbra    d2,.A
  7348.     lea    badprotbit(pc),a0
  7349.     bra    ErrorExit
  7350. .C    rts
  7351.  
  7352. pr_prot    lea    temp2buf(a5),a0        V2.0
  7353. pr_pro2    moveq    #7,d0
  7354.     move.l    fib_Protection(a5),d1
  7355.     eor.b    #$0f,d1
  7356. .A    move.b    #"-",(a0)+
  7357.     btst    d0,d1
  7358.     beq.s    .B
  7359.     move.b    protflags(pc,d0.w),-1(a0)
  7360. .B    dbra    d0,.A
  7361.     clr.b    (a0)
  7362.     lea    temp2buf(a5),a1
  7363.     rts
  7364.  
  7365. protflags    dc.b    'dewrapsh'
  7366.  
  7367. *************************
  7368. *    JOIN        *    V2.3 new written
  7369. *************************
  7370. joinz    clr.l    temp2(a5)
  7371.     bset    #DLjoin,temp2+1(a5)    set join flag
  7372.     bsr    check_q_r
  7373.     clr.l    devproc(a5)
  7374.     clr.l    temp5(a5)    destination file
  7375.     clr.l    temp6(a5)    memory block
  7376.     lea    parm2(a5),a3
  7377.     addq.l    #4,a3
  7378.     tst.l    (a3)+
  7379.     beq    too_less_args    no arg given
  7380. .A    tst.l    (a3)+
  7381.     bne.s    .A
  7382.     move.l    -8(a3),a2    get last parm
  7383.     clr.l    -8(a3)        and remove it
  7384.     move.l    a2,d1
  7385.     bsr    OpenReadWrite
  7386.     move.l    d0,temp5(a5)    open output file and store it
  7387.     beq    DOSerr
  7388.     move.l    d0,d1
  7389.     moveq    #0,d2
  7390.     moveq    #1,d3
  7391.     jsr    _LVOSeek(a6)    look for end, no error checking
  7392.     bsr    GetCopyBlock
  7393.     beq    .F
  7394.     move.l    d0,temp6(a5)
  7395.     bsr    directory2    DO COPY !
  7396.     bsr    FreeCopyBlock
  7397. .F    move.l    temp5(a5),d1
  7398.     jsr    _LVOClose(a6)
  7399.     moveq    #RETURN_OK,d0
  7400.     rts
  7401.  
  7402. JoinFile    ;a0=filename, temp5=outfile, temp6=mem block
  7403.     moveq    #0,d4
  7404.     move.l    a0,d1
  7405.     bsr    OpenOldfile    open input file
  7406.     move.l    d0,d4        d4=input file handle
  7407.     beq    perr3
  7408.     move.l    temp5(a5),d5    d5=output file handle
  7409.     bsr    PerformCopy        Main Stuff !
  7410.     bne.s    .C
  7411.     lea    processOK(pc),a1    all OK
  7412.     bsr    pr_string
  7413.     moveq    #RETURN_OK,d0
  7414. .C    rts
  7415.  
  7416. *************************
  7417. *    MOVE        *    V2.3
  7418. *************************
  7419. movez    clr.l    temp2(a5)
  7420.     bset    #DLmove,temp2+1(a5)    set move flag
  7421.     bset    #DLrename,temp2+1(a5)    set rename flag
  7422.     bset    #DLdelete,temp2(a5)    set delete flag
  7423.     clr.l    temp7(a5)    holds full dest. pathname
  7424.     bra.s    Copy1
  7425.  
  7426. MoveFile    ;Filename in a0
  7427.     move.l    a0,a3
  7428.     move.l    temp7(a5),a0    path
  7429.     move.l    a3,a1        name
  7430.     lea    temp2buf(a5),a2    path+name
  7431.     bsr    addpath
  7432.     move.l    a2,d2
  7433.     move.l    a3,d1
  7434.     jsr    _LVORename(a6)
  7435.     tst.l    d0
  7436.     beq.s    .A
  7437.     lea    moveOK(pc),a1
  7438.     bsr    pr_string
  7439.     moveq    #1,d0
  7440. .A    rts
  7441.  
  7442. *************************
  7443. *    COPY        *    V2.3 new written
  7444. *************************
  7445. copyz    clr.l    temp2(a5)
  7446. Copy1    bset    #DLcopy,temp2+1(a5)    set copy flag
  7447.     bset    #DLquick,temp2(a5)    bit 30=quick flag
  7448.     bsr    check_q_r
  7449.     clr.l    devproc(a5)
  7450.     clr.l    temp5(a5)    destination dir
  7451.     clr.l    temp6(a5)    memory block
  7452.     lea    parm2(a5),a2
  7453.     tst.l    (a2)+
  7454.     beq    too_less_args    *no arg given
  7455.     tst.l    (a2)+
  7456.     bne.s    Copy2
  7457.     lea    null(pc),a2    *one arg -> copy to current dir
  7458.     bra    Copy3b
  7459.  
  7460. Copy2    tst.l    (a2)+
  7461.     bne    Copy3
  7462.     move.l    -8(a2),a0    *two args -> copy to file/dir
  7463.     clr.l    -8(a2)        get it and remove it
  7464.     move.l    a0,a2
  7465.     move.l    parm2(a5),a0
  7466.     bsr    check_wild
  7467.     tst.l    d0
  7468.     beq    Copy3b        wildcards->copy to dir
  7469.     move.l    a2,a0
  7470.     move.b    dotchar(a5),d0
  7471.     bsr    CheckOneChar
  7472.     bne.s    .F
  7473.     lea    CDbackstr(a5),a2    dot->copy to last used dir
  7474.     bra    Copy3b
  7475. .F    btst    #DLmove,temp2+1(a5)
  7476.     beq.s    .B        move: try to rename
  7477.     move.l    parm2(a5),d1
  7478.     move.l    a2,d2
  7479.     jsr    _LVORename(a6)
  7480.     tst.l    d0
  7481.     beq.s    .B        move:    failed
  7482.     move.l    parm2(a5),a1        OK
  7483.     bsr    pr_string
  7484.     bsr    pr_space
  7485.     lea    moveOK(pc),a1
  7486.     bsr    pr_string
  7487.     moveq    #RETURN_OK,d0
  7488.     rts
  7489. .B    move.l    parm2(a5),d1    try to copy file to file:
  7490.     bsr    OpenOldfile    try to open input file    (d4)
  7491.     move.l    d0,d4
  7492.     beq.s    Copy3b        input not found->maybe a dir
  7493.     move.l    a2,d1
  7494.     bsr    OpenNewfile    try to open output file (d5)
  7495.     move.l    d0,d5
  7496.     bne.s    .D
  7497.     bsr    closett
  7498.     bra.s    Copy3b
  7499. .D    move.l    parm2(a5),a1
  7500.     bsr    pr_string
  7501.     bsr    pr_space
  7502.     bsr    GetCopyBlock
  7503.     bne.s    .A
  7504.     bsr    closett
  7505.     bra    resi_no_mem
  7506. .A    bsr    PerformCopy    do copy !
  7507.     move.l    d0,d4
  7508.     bsr    FreeCopyBlock
  7509.     tst.l    d4        error occured ?
  7510.     bne.s    .E
  7511.     btst    #DLmove,temp2+1(a5)    move flag ?
  7512.     beq.s    .C
  7513.     move.l    parm2(a5),a0
  7514.     bsr    DoDelete    move: delete old file
  7515. .C    lea    copyOK(pc),a1        all OK
  7516.     bsr    pr_string
  7517. .E    move.l    d4,d0
  7518.     rts
  7519.  
  7520. Copy3    tst.l    (a2)+        *three or more args -> copy them to dir
  7521.     bne.s    Copy3        look for last parm
  7522.     move.l    -8(a2),a0    get it
  7523.     clr.l    -8(a2)        and remove it
  7524.     move.l    a0,a2
  7525. Copy3b    move.l    a2,d1
  7526.     moveq    #ACCESS_READ,d2
  7527.     jsr    _LVOLock(a6)    try to lock dir
  7528.     move.l    d0,d7
  7529.     bne.s    .B        found
  7530.     jsr    _LVOIoErr(a6)
  7531.     cmp.l    #205,d0        object not found ?
  7532.     beq.s    .C
  7533.     bra    pr_galactic    no
  7534. .C    move.l    a2,d1
  7535.     jsr    _LVOCreateDir(a6)    yes, make dir
  7536.     move.l    d0,d1
  7537.     beq    DOSerr
  7538.     jsr    _LVOUnLock(a6)    unlock and try again
  7539.     move.l    a2,a1
  7540.     bsr    pr_string
  7541.     bsr    pr_space
  7542.     lea    makedirOK(pc),a1
  7543.     bsr    pr_string
  7544.     bra.s    Copy3b
  7545. .B    bsr    fibexam2
  7546.     tst.l    fib_DirEntryType(a5)    file or dir ?
  7547.     bpl.s    .E
  7548.     move.l    d7,d1
  7549.     jsr    _LVOUnLock(a6)    was not a dir
  7550.     move.l    #212,d0
  7551.     bra    pr_galactic
  7552. .E    move.l    d7,temp5(a5)    was a dir: store lock
  7553.     lea    -80(sp),sp
  7554.     move.l    sp,temp7(a5)
  7555.     bsr    AdjustPath    move: get full path
  7556.     move.l    a2,d1
  7557.     jsr    _LVODeviceProc(a6)
  7558.     move.l    d0,devproc(a5)
  7559.     bsr    GetCopyBlock
  7560.     beq    .F
  7561.     bsr    directory2    DO COPY !
  7562.     bsr    FreeCopyBlock
  7563. .F    lea    80(sp),sp    space needed for move
  7564.     move.l    temp5(a5),d1
  7565.     jsr    _LVOUnLock(a6)    unlock dir
  7566.     moveq    #RETURN_OK,d0
  7567.     rts
  7568.  
  7569. GetCopyBlock
  7570.     move.l    copysize(a5),d0
  7571.     bsr    iwantmem    get memory block
  7572.     move.l    d0,temp6(a5)
  7573.     bsr    maybeDOSerr
  7574.     rts
  7575.  
  7576. FreeCopyBlock
  7577.     move.l    temp6(a5),a1
  7578.     move.l    copysize(a5),d0
  7579.     bra    givemem        free memory block
  7580.  
  7581. CopyFileToDir    ;a0=filename
  7582. *current path set, destination path in temp5, memory block in temp6
  7583.     moveq    #0,d4
  7584.     moveq    #0,d5
  7585.     move.l    a0,a2
  7586.     move.l    a0,d1
  7587.     bsr    OpenOldfile    open input file
  7588.     move.l    d0,d4        d4=input file handle
  7589.     beq    perr3        read protected ?
  7590.     move.l    a2,a0
  7591.     lea    temp2buf(a5),a2
  7592.     move.l    a2,a1
  7593.     bsr    rempath
  7594.     move.l    temp5(a5),d1
  7595.     bsr    CurrentDir
  7596.     move.l    d0,a3        a3 holds current dir
  7597.     move.l    a2,d1
  7598.     bsr    OpenNewfile    open output file
  7599.     move.l    d0,d5        d5=output file handle
  7600.     beq    perr4        already exits/disk full ?
  7601.     move.l    a3,d1
  7602.     bsr    CurrentDir
  7603.     bsr    PerformCopy        Main Stuff !
  7604.     bne.s    .C
  7605.     cmp.l    fib_Size(a5),d6
  7606.     beq.s    .B
  7607.     lea    wrongsize(pc),a1    wrong size
  7608.     bsr    pr_string
  7609.     move.l    d6,d0
  7610.     bsr    print10
  7611.     bsr    pr_lf
  7612.     bra.s    .A
  7613. .B    lea    copyOK(pc),a1        all OK
  7614.     bsr    pr_string
  7615. .A    moveq    #RETURN_OK,d0
  7616. .C    rts
  7617.  
  7618. PerformCopy        ;dest. filename in a2, d4,d5:filehandles
  7619.     moveq    #-1,d6        d6 holds maximum filesize
  7620. PerformCopy1
  7621. .A    move.l    d4,d1
  7622.     move.l    temp6(a5),d2
  7623.     move.l    copysize(a5),d3
  7624.     cmp.l    d3,d6
  7625.     bhi.s    .E
  7626.     move.l    d6,d3
  7627. .E    jsr    _LVORead(a6)    read a block
  7628.     move.l    d0,d3
  7629.     bmi    perr2        read error ?
  7630.     beq.s    recoend
  7631.     move.l    d5,d1
  7632.     move.l    temp6(a5),d2
  7633.     jsr    _LVOWrite(a6)    write as much as read
  7634.     tst.l    d0
  7635.     bmi    perr2        disk full ?
  7636.     cmp.l    d0,d3
  7637.     bne    perr2        disk full ?
  7638.     cmp.l    copysize(a5),d3
  7639.     bne.s    .B        buffer not filled by Read
  7640.     lea    dot(pc),a1
  7641.     bsr    pr_string    print dots as progress-indicator
  7642. .B    sub.l    d0,d6        sum up size in d6
  7643.     beq.s    recoend
  7644.     bsr    check_c        check for CTRL-C break
  7645.     beq.s    .A
  7646. recoend    bsr    closett
  7647.     addq.l    #1,d6
  7648.     neg.l    d6        calculate real filesize
  7649. adjust    tst.l    devproc(a5)
  7650.     beq.s    .A
  7651.     move.l    temp5(a5),d1
  7652.     bsr    CurrentDir
  7653.     move.l    d0,a3
  7654.     move.l    a2,d1
  7655.     move.l    fib_Protection(a5),d2
  7656.     jsr    _LVOSetProtection(a6)    set old protection
  7657.     tst.l    d0
  7658.     beq    perr4
  7659. .D    move.l    a2,d1
  7660.     lea    fib_Comment(a5),a0    copy comment
  7661.     move.l    a0,d2
  7662.     jsr    _LVOSetComment(a6)
  7663.     tst.l    d0
  7664.     beq    perr4
  7665. .C    bsr    clearArgs        set old date
  7666.     lea    fib_Date(a5),a0
  7667.     move.l    a0,myArg4(a5)
  7668.     move.l    devproc(a5),packettask(a5)
  7669.     move.l    temp5(a5),myArg2(a5)
  7670.     lea    NewPrintBuffer(a5),a1
  7671.     move.l    a1,d2
  7672.     lsr.l    #2,d2
  7673.     move.l    d2,myArg3(a5)
  7674.     addq.l    #1,a1
  7675.     moveq    #-1,d0
  7676. .B    addq.l    #1,d0
  7677.     move.b    (a2)+,(a1)+
  7678.     bne.s    .B
  7679.     move.b    d0,NewPrintBuffer(a5)
  7680.     moveq    #ACTION_SET_DATE,d0
  7681.     move.l    d0,packettype(A5)
  7682.     bsr    sendpacket
  7683.     beq    perr4
  7684.     move.l    a3,d1
  7685.     bsr    CurrentDir
  7686. .A    moveq    #RETURN_OK,d0
  7687.     rts
  7688.  
  7689. perr4    move.l    a3,d1
  7690.     bsr    CurrentDir
  7691.     bra.s    perr1
  7692. perr2
  7693. perr3    move.l    thistask(a5),a0
  7694.     move.l    pr_Result2(a0),-(sp)
  7695.     bsr    closett
  7696.     move.l    thistask(a5),a0
  7697.     move.l    (sp)+,pr_Result2(a0)
  7698. perr1    jsr    _LVOIoErr(a6)
  7699.     cmp.l    #221,d0            disk full ?
  7700.     bne.s    .A
  7701.     tst.l    devproc(a5)        is dest. filename in a2 ?
  7702.     beq.s    .C
  7703.     move.l    d0,-(sp)
  7704.     move.l    temp5(a5),d1
  7705.     bsr    CurrentDir
  7706.     move.l    d0,a3
  7707.     move.l    a2,d1
  7708.     jsr    _LVODeleteFile(a6)    delete incomlete file
  7709.     move.l    a3,d1
  7710.     bsr    CurrentDir
  7711.     move.l    (sp)+,d0
  7712. .C    move.b    #1,break_flag(a5)    break if disk is full
  7713. .A    bsr    pr_lf
  7714.     bsr    pr_DOSerr
  7715.     moveq    #RETURN_ERROR,d0
  7716.     rts
  7717.  
  7718. closett    move.l    d4,d1    ;close files in d4 & d5
  7719.     beq.s    .A
  7720.     btst    #DLsplit,temp2+1(a5)    split: do not close infile
  7721.     bne.s    .A
  7722.     jsr    _LVOClose(a6)
  7723.     moveq    #0,d4
  7724. .A    move.l    d5,d1
  7725.     beq.s    .B
  7726.     btst    #DLjoin,temp2+1(a5)    join: do not close outfile
  7727.     bne.s    .B
  7728.     jsr    _LVOClose(a6)
  7729.     moveq    #0,d5
  7730. .B    rts
  7731.  
  7732.  
  7733.  
  7734. *************************************************************
  7735. * read a file to memory
  7736. * ENTRY A0=name
  7737. * EXIT  D0=address, D1=size
  7738. readfile    movem.l    d2-d7/a0-a4,-(sp)
  7739.     move.l    a0,d1
  7740.     move.l    a0,a4
  7741.     bsr    OpenOldfile    try to open it in current dir
  7742.     move.l    d0,d4        d4=filehandle
  7743.     bne.s    .A
  7744.     bsr    RequestersOff
  7745.     lea    paths(pc),a0
  7746.     move.l    a4,a1
  7747.     lea    tempbuf(a5),a2
  7748.     bsr    addpath
  7749.     move.l    a2,d1
  7750.     bsr    OpenOldfile    try to open it in S: dir
  7751.     move.l    d0,d4
  7752.     beq    reader
  7753.     bsr    RequestersOn
  7754.  
  7755. .A    move.l    d4,d7        d7=filehandle to close
  7756.     bsr    readdata        open succeded
  7757.     move.l    d4,d1
  7758.     jsr    _LVOClose(a6)    close it
  7759. readfileend
  7760.     move.l    d6,d0
  7761.     move.l    d5,d1
  7762.     movem.l    (sp)+,d2-d7/a0-a4
  7763.     rts
  7764.  
  7765. * read things from stdin to memory
  7766. * EXIT  D0=address, D1=size
  7767. readstdin    movem.l    d2-d7/a0-a4,-(sp)
  7768.     move.l    inhandle(a5),d4
  7769.     moveq    #0,d7        do not close filehandle
  7770.     bsr    readdata
  7771.     bra.s    readfileend
  7772.  
  7773. * read the contents of a file to memory
  7774. * ENTRY: d4=filehandle
  7775. * EXIT:  d5=size, d6=address of memory block
  7776. readdata    moveq    #1,d3
  7777.     moveq    #0,d2
  7778.     move.l    d4,d1
  7779.     jsr    _LVOSeek(a6)
  7780.     tst.l    d0
  7781.     bmi.s    reader2
  7782.     moveq    #-1,d3
  7783.     moveq    #0,d2
  7784.     move.l    d4,d1
  7785.     jsr    _LVOSeek(a6)
  7786.     move.l    #-148,d1
  7787.     move.l    d0,d5    d5=size, handles also powerpacked files
  7788.     beq.s    reader4
  7789.     bmi.s    reader2
  7790.     bsr    iwantmem
  7791.     move.l    d0,d6    d6=addr
  7792.     beq    reader2
  7793.     move.l    d6,d2
  7794.     move.l    d5,d3
  7795.     move.l    d4,d1
  7796.     jsr    _LVORead(a6)    READ IT
  7797.     tst.l    d0
  7798.     bmi    reader3
  7799.     rts
  7800.  
  7801. reader4    move.l    d1,-(sp)
  7802.     bra.s    reade22
  7803. reader3    move.l    d6,a1
  7804.     move.l    d5,d0
  7805.     bsr    givemem
  7806. reader2    move.l    thistask(a5),a0
  7807.     move.l    pr_Result2(a0),-(sp)
  7808. reade22    move.l    d7,d1
  7809.     beq.s    .A
  7810.     jsr    _LVOClose(a6)
  7811. .A    move.l    thistask(a5),a0
  7812.     move.l    (sp)+,pr_Result2(a0)
  7813. reader    bsr    RequestersOn
  7814.     bra    DOSerr
  7815.  
  7816. *****************
  7817. *    MORE    *
  7818. *****************
  7819. morez    lea    parm2(a5),a0
  7820.     tst.b    redirect_in(a5)
  7821.     bne.s    .A
  7822.     move.l    (a0),d2
  7823.     beq    too_less_args
  7824.     addq.l    #4,a0
  7825. .A    moveq    #0,d4
  7826.     move.l    (a0),d0
  7827.     beq    .C
  7828.     move.l    d0,a1
  7829.     bsr    convert_ASCII_to_num
  7830.     beq    bad_number_error
  7831.     tst.w    d0
  7832.     beq.s    .C
  7833.     move.w    d0,d4
  7834.  
  7835. .C    tst.b    redirect_in(a5)
  7836.     bne.s    .B
  7837.     move.l    d2,a0
  7838.     bsr    readfile    read from file
  7839.     bra.s    .D
  7840. .B    bsr    readstdin    read from inhandle
  7841. .D    moveq    #0,d2
  7842. ViewMore        ;Jump-In to review the buffer
  7843.     move.l    d0,-(sp)    push address
  7844.     move.l    d1,-(sp)    push size
  7845.     move.l    d0,a0
  7846.     cmp.l    #$3f3,(a0)
  7847.     bne.s    .B
  7848.     move.l    #212,d0
  7849.     bsr    pr_DOSerr
  7850.     bra.s    .A
  7851. .B    bsr    make_screen
  7852. .A    move.l    (sp)+,d0
  7853.     move.l    (sp)+,a1
  7854.     bsr    givemem
  7855.     moveq    #RETURN_OK,D0
  7856.     RTS
  7857.  
  7858. make_screen    * more main-routine, also used for help
  7859. * Entry: d0=start adress, d1=length, d4=number of lines or 0, d2=lookback
  7860.     movem.l    d0-d2,-(sp)
  7861.     addq.b    #1,noreview_flag(a5)
  7862.     bsr    pr_hide_cursor
  7863.     bsr    raw_on
  7864.     btst    #FLcutline,Flags+3(a5)
  7865.     beq.s    .G
  7866.     lea    cutontx(pc),a1
  7867.     bsr    pr_string
  7868. .G    tst.w    d4
  7869.     bne.s    .A
  7870.     bsr    GetWinSize
  7871.     move.w    d0,d4
  7872. .A    movem.l    (sp)+,d0-d2
  7873.     move.w    d4,line_count(a5)
  7874.     move.l    d0,d5    d5=start
  7875.     move.l    d0,a4    a4=ptr
  7876.     move.l    d0,a3
  7877.     move.l     d0,d6
  7878.     add.l    d1,d6    d6=end addr
  7879.     tst.l    d2
  7880.     beq.s    mk_screen
  7881.     move.l    d6,a4
  7882.     bra    look_back
  7883. mk_screen
  7884.     lea    clrhide(pc),a1
  7885.     bsr    pr_string
  7886.     move.w    line_count(a5),d2
  7887.     subq.w    #1,d2
  7888.     move.l    a4,-(sp)
  7889.     moveq    #0,d0
  7890.     bra.s    .A
  7891. .C    moveq    #1,d0    PRINT SCREEN FULL OF LINES
  7892. .A;    bsr    pr_line
  7893. .B    cmp.l    d6,a4    check against end
  7894.     beq.s    .E
  7895.     move.b    (a4)+,d0
  7896.     cmp.b    #LF,d0
  7897.     bne.s    .B
  7898.     dbra    d2,.C
  7899.     move.l    a4,a3    A3 points to end of page marker    
  7900. .E    move.l    a4,d7    D7 points to end
  7901.     move.l    (sp)+,a4
  7902. ;    bra    waitabit
  7903.  
  7904.     move.l    a4,d2
  7905.     move.l    outhandle(a5),d1
  7906.     beq.s    waitabit
  7907.     move.l    d7,d3
  7908.     sub.l    a4,d3
  7909.     subq.l    #1,d3
  7910.     bmi.s    waitabit    don't print if 0
  7911.     cmp.l    d7,d6
  7912.     bne.s    .D
  7913.     cmp.l    a3,d7
  7914.     beq.s    .D
  7915.     addq.l    #1,d3
  7916. .D    jsr    _LVOWrite(a6)
  7917.  
  7918. waitabit    
  7919.     move.l    stdin(a5),d1
  7920.     beq    ExitZShell
  7921.     lea    tempbytes(a5),a0
  7922.     move.l    a0,d2
  7923.     moveq    #1,d3
  7924.     jsr    _LVORead(a6)        wait for space key
  7925. .A    moveq    #0,d0            clear top bytes
  7926.     move.b    tempbytes(a5),d0    test byte of input line
  7927.     cmp.b    #$9b,d0
  7928.     beq.s    waitabit        CSI ? Try again !
  7929. tastes    cmp.b    #'a',d0
  7930. ;    blo.s    go_upper
  7931. ;    sub.b    #$20,d0
  7932.  
  7933. go_upper    cmp.b    morekeys+1(a5),d0        cursor down ?
  7934.     beq.s    .G
  7935.     cmp.b    #"2",d0
  7936.     bne.s    ck_up
  7937. .G    cmp.l    d7,d6
  7938.     beq    waitabit
  7939.     lea    scroll_up_tx(pc),a1    SCROLL UP ONE LINE,
  7940.     bsr    pr_string    SEND CURSOR TO START OF LINE
  7941. .B    cmp.l    d6,a4    advance one line
  7942.     beq.s    .C
  7943.     move.b    (a4)+,d0
  7944.     cmp.b    #LF,d0
  7945.     bne.s    .B
  7946. .C    cmp.l    d6,a3    move a3 down one line too
  7947.     beq.s    .D
  7948.     move.b    (a3)+,d0
  7949.     cmp.b    #LF,d0
  7950.     bne.s    .C
  7951. .D    move.l    a4,-(sp)
  7952.     move.l    d7,a4
  7953. ;    cmp.l    d7,d6
  7954. ;    beq.s    .A
  7955.     moveq    #0,d0
  7956.     bsr    pr_line    print line from d7
  7957. .A    cmp.l    d6,a4    advance D7 one line
  7958.     beq.s    .E
  7959.     move.b    (a4)+,d0
  7960.     cmp.b    #LF,d0
  7961.     bne.s    .A
  7962. .E    move.l    a4,d7
  7963.     move.l    (sp)+,a4
  7964.     bra    waitabit
  7965.  
  7966. ck_up    cmp.b    morekeys+0(a5),d0        V2.0    cursor up ?
  7967.     beq.s    .G
  7968.     cmp.b    #"8",d0
  7969.     bne.s    ck_fwd
  7970. .G    cmp.l    d5,a4
  7971.     beq    waitabit
  7972.     lea    scroll_down_tx(pc),a1    SCROLL DOWN ONE LINE,
  7973.     bsr    pr_string    SEND CURSOR TO TOP LEFT
  7974.     cmp.l    d5,a4
  7975.     bls.s    .E
  7976.     subq.l    #1,a4
  7977. .B    cmp.l    d5,a4
  7978.     beq.s    .A
  7979.     cmp.b    #LF,-(a4)
  7980.     bne.s    .B
  7981.     addq.l    #1,a4
  7982. .A    moveq    #0,d0
  7983.     bsr    pr_line
  7984. .E    move.l    d7,a3
  7985.     cmp.l    d5,a3
  7986.     beq.s    .C
  7987.     subq.l    #1,a3
  7988. .D    cmp.l    d5,a3
  7989.     beq.s    .C
  7990.     cmp.b    #LF,-(a3)
  7991.     bne.s    .D
  7992.     addq.l    #1,a3
  7993. .C    move.l    a3,d7
  7994.     lea    temp2buf(a5),a1
  7995.     move.l    a1,a0
  7996.     move.b    #$9b,(a0)+
  7997.     move.w    line_count(a5),d0
  7998.     bsr    dec2asc
  7999.     move.b    #"H",(a0)+
  8000.     clr.b    (a0)
  8001.     bsr    pr_string    CURSOR some lines down
  8002.     bra    waitabit
  8003.  
  8004. ck_fwd    cmp.b    morekeys+2(a5),d0    cursor right ?
  8005.     beq.s    .A
  8006.     cmp.b    #"3",d0
  8007.     beq.s    .A
  8008.     cmp.b    #" ",d0
  8009.     bne.s    ck_top
  8010. .A    cmp.l    d7,d6        one page forward
  8011.     beq    waitabit
  8012.     move.l    a3,a4
  8013.     bra    mk_screen
  8014. ck_top    cmp.b    morekeys+5(a5),d0    shift cursor up ?
  8015.     beq.s    .A
  8016.     cmp.b    #"7",d0
  8017.     bne.s    ck_bot
  8018. .A    cmp.l    d5,a4        start of text
  8019.     beq    waitabit
  8020.     move.l    d5,a4
  8021.     bra    mk_screen
  8022. ck_bot    cmp.b    morekeys+4(a5),d0    shift cursor down ?
  8023.     beq.s    .A
  8024.     cmp.b    #"1",d0
  8025.     bne.s    ck_back
  8026. .A    cmp.l    a3,d6        end of text
  8027.     beq    waitabit
  8028.     move.l    d6,a4
  8029.     bra.s    look_back
  8030. ck_back    cmp.b    morekeys+3(a5),d0    cursor left ?
  8031.     beq.s    .A
  8032.     cmp.b    #"9",d0
  8033.     beq.s    .A
  8034.     cmp.b    #8,d0    backspace
  8035.     bne.s    ck_nkey
  8036. .A    cmp.l    d5,a4        one page back
  8037.     beq    waitabit
  8038. look_back
  8039.     move.w    line_count(a5),d1
  8040. mlook2    cmp.l    d5,a4    check against start
  8041.     beq.s    .E
  8042.     move.b    -(a4),d0
  8043.     cmp.b    #LF,d0
  8044.     bne.s    mlook2
  8045.     dbra    d1,mlook2
  8046.     lea    1(a4),a4
  8047. .E    bra    mk_screen
  8048.  
  8049.  
  8050. ck_nkey    cmp.b    morekeys+8(a5),d0    V2.7    search next string ?
  8051.     bne.s    ck_skey
  8052.     lea    tempbuf(a5),a1
  8053.     bra.s    more_sn
  8054.  
  8055. ck_skey    cmp.b    morekeys+7(a5),d0    V2.0    search string ?
  8056.     bne.s    ck_jkey
  8057.     bsr    raw_off
  8058.     lea    msearch(pc),a1
  8059.     bsr    pr_string
  8060.     lea    tempbuf(a5),a2
  8061.     move.b    (a2),d4        save first char
  8062.     move.l    a2,d2
  8063.     moveq    #120,d3
  8064.     move.l    stdin(a5),d1
  8065.     beq.s    more_se
  8066.     jsr    _LVORead(a6)
  8067.     tst.l    d0
  8068.     bmi.s    more_se
  8069.     move.l    a2,a1
  8070.     add.l    d0,a2
  8071.     subq.l    #1,a2
  8072.     move.b    d4,(a2)
  8073.     cmp.l    a1,a2        just pressed return ?
  8074.     beq.s    more_sn
  8075.     clr.b    (a2)    no
  8076. more_sn    move.l    d5,a3
  8077.     move.l    a4,a0
  8078.     bsr    find_end_of_line
  8079.     move.l    a0,a2
  8080.     move.l    d6,a0
  8081.     bsr    searchSTR
  8082.     cmp.b    #LF,d0
  8083.     bne.s    more_se
  8084.     move.l    a1,a4    set begin of line on top
  8085.     bra.s    more_sx
  8086. more_se    bsr    DisplayBeep
  8087. more_sx    bsr    raw_on
  8088.     bra    mk_screen
  8089.  
  8090. ck_jkey    cmp.b    morekeys+9(a5),d0    V2.3    jump to % ?
  8091.     bne.s    ck_wkey
  8092.     bsr    raw_off
  8093.     lea    mjump(pc),a1
  8094.     bsr    pr_string
  8095.     lea    tempbuf(a5),a2
  8096.     move.l    a2,d2
  8097.     moveq    #120,d3
  8098.     move.l    stdin(a5),d1
  8099.     beq.s    .A
  8100.     jsr    _LVORead(a6)
  8101.     tst.l    d0
  8102.     bmi.s    .A
  8103.     move.l    a2,a1
  8104.     add.l    d0,a2
  8105.     subq.l    #1,a2
  8106.     cmp.l    a1,a2        just pressed return ?
  8107.     beq.s    .A
  8108.     clr.b    (a2)    no
  8109.     bsr    convert_ASCII_to_num
  8110.     beq.s    .A
  8111.     moveq    #100,d1
  8112.     cmp.l    d1,d0
  8113.     bhi.s    .A
  8114.     move.l    d6,d1
  8115.     sub.l    d5,d1    calc % of size
  8116.     bsr    mult_32x32
  8117.     moveq    #100,d1
  8118.     bsr    div_32
  8119.     move.l    d5,a4
  8120.     add.l    d0,a4    new pointer
  8121.     bsr    raw_on
  8122.     moveq    #0,d1
  8123.     bra    mlook2    search begin of line
  8124. .A    bsr    raw_on
  8125.     bra    mk_screen
  8126.  
  8127. ck_wkey    cmp.b    morekeys+10(a5),d0    V2.3    write text to file (or print) ?
  8128.     bne.s    ck_hkey
  8129.     bsr    raw_off
  8130.     lea    mwrite(pc),a1
  8131.     bsr    pr_string
  8132.     lea    tempbuf(a5),a2
  8133.     move.l    a2,d2
  8134.     moveq    #120,d3
  8135.     move.l    stdin(a5),d1
  8136.     beq.s    .C
  8137.     jsr    _LVORead(a6)
  8138.     move.l    a2,a1
  8139.     add.l    d0,a2
  8140.     subq.l    #1,a2
  8141.     clr.b    (a2)        null-end
  8142.     cmp.l    a1,a2        just pressed return ?
  8143.     beq.s    .C        yes,quit
  8144.     move.l    a1,d1
  8145.     bsr    OpenNewfile
  8146.     move.l    d0,d4
  8147.     beq.s    .C
  8148.     move.l    d4,d1
  8149.     move.l    d5,d2
  8150.     move.l    d6,d3
  8151.     sub.l    d2,d3
  8152.     jsr    _LVOWrite(a6)
  8153.     move.l    d4,d1
  8154.     jsr    _LVOClose(a6)
  8155. .C    bsr    raw_on
  8156.     bra    mk_screen
  8157.  
  8158. ck_hkey    cmp.b    morekeys+12(a5),d0    V2.3    help info ?
  8159.     beq.s    .A
  8160.     cmp.b    #$3f,d0        help key ?
  8161.     bne.s    ck_rkey
  8162. .A    move.l    d6,d2
  8163.     sub.l    d5,d2
  8164.     move.l    d2,-(sp)
  8165.     move.l    a4,d0
  8166.     sub.l    d5,d0
  8167.     moveq    #100,d1
  8168.     bsr    mult_32x32
  8169.     move.l    d2,d1
  8170.     bsr    div_32
  8171.     move.w    d0,-(sp)
  8172.     move.l    sp,a1
  8173.     lea    helpmor(pc),a0
  8174.     bsr    new_print
  8175.     addq.l    #6,sp
  8176.     bra    waitabit
  8177.  
  8178. ck_rkey    cmp.b    morekeys+11(a5),d0    V2.3    resized window ?
  8179.     bne.s    unknown_key
  8180.     bsr    GetWinSize
  8181.     move.w    d0,line_count(a5)
  8182.     bra    mk_screen
  8183.  
  8184. unknown_key
  8185.     cmp.b    morekeys+6(a5),d0    quit more ?
  8186.     beq.s    .A
  8187.     cmp.b    #27,d0        ESC key ?
  8188.     bne    waitabit
  8189. .A    btst    #FLcutline,Flags+3(a5)    unknown key to exit !
  8190.     beq.s    .G
  8191.     lea    cutofftx(pc),a1
  8192.     bsr    pr_string
  8193. .G    bsr    pr_show_cursor
  8194.     bsr    pr_lf
  8195.     bsr    raw_off
  8196.     subq.b    #1,noreview_flag(a5)
  8197.     moveq    #RETURN_OK,d0
  8198.     rts
  8199.  
  8200. find_end_of_line
  8201. .B    cmp.l    d6,a0    check against end
  8202.     bhs.s    .A
  8203.     move.b    (a0)+,d0
  8204.     cmp.b    #LF,d0
  8205.     bne.s    .B
  8206.     lea    -1(a0),a0
  8207. .A    rts
  8208.  
  8209. ** PRINT STRING AT A4 ENDING IN LF
  8210. pr_line    movem.l    d0-d4/a0,-(sp)
  8211.     move.l    d0,d4
  8212.     move.l    a4,d2
  8213.     move.l    outhandle(a5),d1
  8214.     beq.s    .C
  8215.     move.l    a4,a0
  8216.     bsr    find_end_of_line
  8217.     sub.l    a4,a0
  8218.     move.l    a0,d3
  8219.     tst.l    d4
  8220.     beq.s    .A
  8221.     subq.l    #1,d2
  8222.     addq.l    #1,d3
  8223. .A    tst.l    d3
  8224.     beq.s    .C    don't print if 0
  8225.     jsr    _LVOWrite(a6)
  8226. .C    movem.l    (sp)+,d0-d4/a0
  8227.     rts
  8228.  
  8229. *****************
  8230. *    TYPE    *        Type out ASCII file command    
  8231. *****************
  8232. typez    bsr    pr_hide_cursor
  8233.     tst.b    redirect_in(a5)
  8234.     beq.s    .C
  8235.     bsr    readstdin    read from inhandle
  8236.     bra.s    .D
  8237. .C    move.l    parm2(a5),d0
  8238.     beq    too_less_args
  8239.     move.l    d0,a0
  8240.     bsr    readfile    read from file
  8241. .D    move.l    d0,-(sp)    push address
  8242.     move.l    d1,-(sp)    push size
  8243.     move.l    d0,a4    a4=ptr
  8244.     move.l     d0,d6
  8245.     add.l    d1,d6    d6=end addr
  8246. next_scr    bsr    pr_screen
  8247. freef1    move.l    (sp)+,d0
  8248.     move.l    (sp)+,a1
  8249.     bsr    givemem
  8250.     moveq    #RETURN_OK,D0
  8251.     RTS
  8252.  
  8253. ** ENTRY D6=end of file A4=current pos
  8254. pr_screen    bsr    check_c
  8255.     bne    type_break
  8256.     moveq    #0,d0
  8257.     bsr    pr_line
  8258.     bsr    pr_lf
  8259. .B    cmp.l    d6,a4    check against end
  8260.     bhs.s    type_break
  8261.     move.b    (a4)+,d0
  8262.     cmp.b    #LF,d0
  8263.     bne.s    .B
  8264.     bra.s    pr_screen
  8265. type_break
  8266.     moveq    #RETURN_OK,D0
  8267.     rts
  8268.  
  8269. ***********************
  8270. * EXECUTE SCRIPT FILE *
  8271. ***********************
  8272. executez    ;execute AmigaDOS script
  8273.     move.l    parm2(a5),d0
  8274.     beq    too_less_args
  8275.     move.l    d0,a0
  8276.     lea    ZShellName(pc),a1
  8277.     bsr    CheckOpt    look for ZSHELL option
  8278.     beq.s    execzsh
  8279.     lea    tempbuf(a5),a0
  8280.     move.l    a0,d1
  8281.     lea    exectx+1(pc),a1
  8282. .A    move.b    (a1)+,(a0)+    "execute"
  8283.     bne.s    .A
  8284.     move.b    #" ",-1(a0)    space
  8285.     lea    CLIbuf(a5),a1
  8286. .B    move.b    (a1)+,(a0)+    filename & args
  8287.     bne.s    .B
  8288.     move.b    #LF,-1(a0)    linefeed
  8289.     lea    endcltx+1(pc),a1
  8290. .D    move.b    (a1)+,(a0)+    "endcli"
  8291.     bne.s    .D
  8292.     move.l    thistask(a5),a1
  8293.     move.l    pr_CIS(a1),d2
  8294.     move.l    pr_COS(a1),d3
  8295.     jsr    _LVOExecute(a6)    execute AmigaDOS script
  8296.     moveq    #RETURN_OK,d0
  8297.     rts
  8298.  
  8299. execzsh    tst.b    redirect_in(a5)
  8300.     beq.s    .C
  8301.     bsr    readstdin    read from inhandle
  8302.     bra.s    xz4
  8303. .C    move.l    parm3(a5),d0
  8304.     beq    too_less_args
  8305.     move.l    d0,a0        read from file
  8306. * Execute ZShell script
  8307. xz2    bsr    readfile    A0 pts to filename
  8308. xz4    move.l    d0,a0
  8309.     cmp.l    #$000003f3,(a0)    is it executable ?
  8310.     beq.s    exerr
  8311.     addq.l    #4,sp        kill return address
  8312. xz3    move.l    d0,a0
  8313.     cmp.w    #"/*",(a0)
  8314.     beq.s    xrexx
  8315.     move.l    d1,scsize(a5)
  8316.     move.l    d0,scaddr(a5)
  8317.     move.l    d0,scptr(a5)
  8318.     move.b    #1,scflag(a5)    make shell think text lines are in memory
  8319.     clr.l    mult_comm_ptr(a5)
  8320.     bra    chorus
  8321. exerr    moveq    #RETURN_ERROR,d0
  8322.     rts
  8323. xrexx    move.l    d0,a1        execute AREXX-script
  8324.     move.l    d1,d0
  8325.     bsr    givemem        kill script
  8326.     lea    CLIbuf(a5),a0
  8327.     move.l    parm1(a5),d0
  8328.     beq.s    .A
  8329.     move.l    d0,a1
  8330. .B    move.b    (a1)+,(a0)+    copy rexx-file to CLIbuf
  8331.     bne.s    .B
  8332. .A    lea    rexxtx(pc),a1
  8333.     move.l    a1,parm1(a5)
  8334.     bra    notfound    execute archie3
  8335.  
  8336. *****************
  8337. *    ECHO    *
  8338. *****************
  8339. echoz    lea    parm2(a5),a3
  8340.     move.l    (a3)+,d0
  8341.     beq.s    .B
  8342.     bra.s    .D
  8343. .A    move.l    (a3)+,d0
  8344.     bne.s    .C
  8345. .B    moveq    #RETURN_OK,d0
  8346.     rts
  8347. .C    bsr    pr_space
  8348. .D    bsr    parse_echo
  8349.     bsr    pr_string
  8350.     bra    .A
  8351.  
  8352. parse_echo        ;parse string in d0 in place
  8353.     move.l    a2,-(sp)
  8354.     move.l    d0,a0
  8355.     move.l    a0,a1
  8356.     move.l    a0,a2
  8357.     bra.s    .C
  8358. .B    move.b    d0,(a2)+
  8359. .C    move.b    (a0)+,d0
  8360.     beq.s    .A
  8361.     cmp.b    #$5c,d0 ;\    Ignore Specialchar
  8362.     bne.s    .D
  8363.     move.b    (a0)+,d0
  8364.     beq.s    .A
  8365.     bra.s    .B
  8366. .D    cmp.b    #'^',d0        ^-Character
  8367.     bne.s    .B
  8368.     move.b    (a0)+,d0
  8369.     beq.s    .A
  8370.     cmp.b    #"*",d0
  8371.     bne.s    .G
  8372.     move.b    #$9b,d0
  8373.     bra.s    .B
  8374. .G    cmp.b    #"$",d0        Number given ?
  8375.     beq.s    .F
  8376.     cmp.b    #"0",d0
  8377.     blo.s    .E
  8378.     cmp.b    #"9",d0
  8379.     bhi.s    .E
  8380. .F    subq.l    #1,a0
  8381.     movem.l    d1/d2/a1,-(sp)
  8382.     move.l    a0,a1
  8383.     bsr    convert_ASCII_to_num
  8384.     lea    -1(a1),a0
  8385.     movem.l    (sp)+,d1/d2/a1
  8386.     cmp.b    #".",(a0)
  8387.     bne.s    .B
  8388.     addq.l    #1,a0
  8389.     bra.s    .B        Number was given
  8390. .E    and.b    #$3f,d0        Control Char
  8391.     bra.s    .B
  8392. .A    clr.b    (a2)+
  8393.     move.l    (sp)+,a2
  8394.     rts
  8395.  
  8396. *****************
  8397. *    CLS    *
  8398. *****************
  8399. clsz    lea    clstx(pc),a1
  8400.     bsr    pr_string
  8401.     moveq    #RETURN_OK,d0
  8402.     rts
  8403.  
  8404. *****************
  8405. *    AVAIL    *
  8406. *****************
  8407. availz    tst.l    parm2(a5)
  8408.     beq.s    .A
  8409.     move.l    parm2(a5),a0
  8410.     bsr    return_dash_option
  8411.     cmp.b    #'C',d0
  8412.     bne.s    .A
  8413.     bsr    giveman        free some memory
  8414.     bsr    FreeFNC
  8415.     move.l    4.w,a6
  8416.     moveq    #-1,d0        Free mem
  8417.     move.l    #$00002711,d1    MAGIC NUMBER (from FIDO-net)
  8418.     jsr    _LVOAllocMem(a6)
  8419.     jsr    _LVOForbid(a6)
  8420.     movea.l    a6,a0
  8421.     moveq    #72,d0
  8422.     add.l    d0,a0
  8423.     moveq    #15,d0        free 16 interrupts
  8424.     moveq    #-1,d1
  8425.     moveq    #12,d2
  8426. .B    add.l    d2,a0
  8427.     cmp.l    (a0),d1
  8428.     bne.s    .C
  8429.     cmp.l    4(a0),d1
  8430.     bne.s    .C
  8431.     clr.l    (a0)
  8432.     clr.l    4(a0)
  8433. .C    dbra    d0,.B
  8434.     jsr    _LVOPermit(a6)
  8435.     move.l    dosbase(a5),a6
  8436. .A    lea    -12(sp),sp    show mem
  8437.     lea    (sp),a0
  8438.     bsr    memory_info
  8439.     move.l    a0,a1
  8440.     lea    memess(pc),a0
  8441.     bsr    new_print    show memory
  8442.     lea    12(sp),sp
  8443.     moveq    #RETURN_OK,d0
  8444.     rts
  8445.  
  8446. ** MEM INFO :RETURN 3 LONGWORDS AT A0 -> FREE CHIP,FAST,TOTAL
  8447. memory_info
  8448.     movem.l    a0-a2/a6,-(sp)
  8449.     move.l    a0,a2
  8450.     move.l    4.w,a6
  8451.     jsr    _LVOForbid(a6)    ; don't let 'em change while we ask
  8452.     move.l    #MEMF_CHIP,d1    ; ok, check free chip
  8453.     jsr    _LVOAvailMem(a6)    ; ask system how much there is
  8454.     move.l    d0,(a2)
  8455.     move.l    #MEMF_FAST,d1    ; check fast mem avail
  8456.     jsr    _LVOAvailMem(a6)
  8457.     move.l    d0,4(a2)
  8458.     move.l    #MEMF_PUBLIC,d1     ; get all available memory
  8459.     jsr    _LVOAvailMem(a6)
  8460.     move.l    d0,8(a2)
  8461.     jsr    _LVOPermit(a6)
  8462.     movem.l    (sp)+,a0-a2/a6
  8463.     rts
  8464.  
  8465. *************************
  8466. *    RELABEL     *
  8467. *************************
  8468. relabelz    tst.l    parm3(a5)
  8469.     beq    too_less_args
  8470.     move.l    parm2(a5),a0
  8471.     bsr    check_for_colon
  8472.     bne    no_col
  8473. .D    move.l    parm2(a5),d1    PARM2=DF0: etc
  8474.     jsr    _LVODeviceProc(a6)
  8475.     tst.l    d0
  8476.     beq    DOSerr
  8477.     move.l    d0,packettask(a5)
  8478.     lea    tempbuf(a5),a2    A2=destination
  8479.     move.l    a2,d0
  8480.     lsr.l    #2,d0
  8481.     bsr    clearArgs
  8482.     move.l    d0,myArg1(a5)    BPTR to my string
  8483.     move.l    parm3(a5),a0    NewName
  8484.     lea    1(a2),a1    A1=after count
  8485.     moveq    #0,d0
  8486. .A    move.b    (a0)+,(a1)+
  8487.     addq.l    #1,d0
  8488.     cmp.b    #':',(a0)    ALLOW FOR IDIOTS WHO PUT : ON END
  8489.     beq.s    .C
  8490.     tst.b    (a0)
  8491.     bne.s    .A
  8492. .C    clr.b    (a1)
  8493.     move.b    d0,(a2)
  8494.     moveq    #ACTION_RENAME_DISK,d0
  8495.     move.l    d0,packettype(a5)    TYPE=RENAME_DISK
  8496.     bsr    sendpacket
  8497.     bsr    PKTerr
  8498.     bsr    changedisk    ;(moved to dc)
  8499. *    bsr    eval_CD        -IS MORE ELEGANT IF I LEAVE OUT.
  8500.     moveq    #RETURN_OK,d0    USER WILL HAVE TO TYPE CD TO CHANGE
  8501.     rts            PROPER.
  8502.  
  8503. *************************
  8504. *    ADDBUFFERS    *
  8505. *************************
  8506. addbuffersz
  8507.     cmp.w    #36,kickver(a5)
  8508.     blo.s    .A
  8509.     move.l    parm2(a5),d3
  8510.     beq    too_less_args
  8511.     move.l    parm3(a5),d0
  8512.     beq.s    .B
  8513.     move.l    d0,a1
  8514.     bsr    convert_ASCII_to_num
  8515.     beq    bad_number_error
  8516. .B    move.l    d3,d1
  8517.     move.l    d0,d2
  8518.     jsr    _LVOAddBuffers(a6)
  8519.     tst.l    d0
  8520.     beq    DOSerr
  8521.     moveq    #-1,d1
  8522.     cmp.l    d1,d0
  8523.     bne.s    .C
  8524.     jsr    _LVOIoErr(a6)
  8525. .C    move.l    d0,-(sp)
  8526.     move.l    d3,-(sp)
  8527.     lea    (sp),a1
  8528.     lea    addbufftx(pc),a0
  8529.     bsr    new_print
  8530.     addq.l    #8,sp
  8531.     bra.s    .D
  8532.  
  8533. .A    tst.l    parm3(a5)
  8534.     beq    too_less_args
  8535.     bsr    clearArgs
  8536.     move.l    parm3(a5),a1
  8537.     bsr    convert_ASCII_to_num
  8538.     beq    bad_number_error
  8539.     cmp.l    #32767,d0
  8540.     bhi    bad_number_error
  8541.     move.l    d0,myArg1(a5)
  8542.     move.l    parm2(a5),d1    PARM2=DF0: etc
  8543.     jsr    _LVODeviceProc(a6)
  8544.     tst.l    d0
  8545.     beq    DOSerr
  8546.     move.l    d0,packettask(a5)
  8547.     moveq    #ACTION_MORE_CACHE,d0
  8548.     move.l    d0,packettype(A5)
  8549.     bsr    sendpacket
  8550.     bsr    PKTerr
  8551. .D    moveq    #RETURN_OK,d0
  8552.     rts
  8553.  
  8554. *************************
  8555. *    KILL    *
  8556. *************************
  8557. killz    move.l    parm2(a5),d1
  8558.     beq    too_less_args
  8559.     move.l    d1,a0
  8560.     bsr    check_for_colon
  8561.     bne.s    .A
  8562.     bsr    clearArgs    kill filesystemhandler
  8563.     jsr    _LVODeviceProc(a6)    PARM2=DF0: etc
  8564.     tst.l    d0
  8565.     beq    DOSerr
  8566.     move.l    d0,packettask(a5)
  8567.     moveq    #ACTION_DIE,d0
  8568.     move.l    d0,packettype(A5)
  8569.     bsr    sendpacket
  8570.     bsr    PKTerr
  8571. .B    moveq    #RETURN_OK,d0
  8572.     rts
  8573.  
  8574. .A    move.l    d1,a2        kill task or cli-process
  8575.     bsr    findtsk
  8576.     beq.s    .B
  8577.     move.l    a0,a2
  8578.     move.l    pr_CIS(a2),d1
  8579.     beq.s    .C
  8580.     jsr    _LVOClose(a6)
  8581. .C    move.l    pr_COS(a2),d1
  8582.     beq.s    .D
  8583.     jsr    _LVOClose(a6)
  8584.     moveq    #25,d1
  8585.     jsr    _LVODelay(a6)
  8586. .D    move.l    4.w,a6
  8587.     jsr    _LVOForbid(a6)
  8588.     move.l    a2,a1
  8589.     jsr    _LVORemTask(a6)
  8590.     jsr    _LVOPermit(a6)
  8591.     move.l    dosbase(a5),a6
  8592.     bra.s    .B
  8593.  
  8594. *************************
  8595. *    SETDATE        *
  8596. *************************
  8597. setdatez tst.l    parm2(a5)
  8598.     beq    too_less_args
  8599.     move.l    parm2(a5),a2
  8600.     bsr    clearArgs
  8601.     lea    date_mark(a5),a0
  8602.     lea    (a0),a3
  8603.     move.l    a0,myArg4(a5)    ;APTR datestamp
  8604.     bsr    get_time
  8605.     tst.l    parm3(a5)
  8606.     beq    nospda
  8607.     move.l    a2,d1
  8608.     moveq    #ACCESS_READ,d2
  8609.     jsr    _LVOLock(a6)
  8610.     move.l    d0,d7
  8611.     beq    DOSerr
  8612.     bsr    fibexam2
  8613.     move.l    d7,d1
  8614.     jsr    _LVOUnLock(a6)
  8615.     lea    -14(sp),sp
  8616.     lea    (sp),a0
  8617.     lea    fib_Date(a5),a1
  8618.     bsr    convert_time
  8619.     lea    parm3(a5),a0
  8620.     lea    (sp),a1
  8621.     bsr    settime
  8622.     move.w    12(sp),d1
  8623.     lea    14(sp),sp
  8624.     tst.l    d0
  8625.     beq    .B
  8626.     rts
  8627.  
  8628. .B    lea    (a3),a0
  8629.     move.l    d5,(a0)+    ;days
  8630.     divu    #60,d6
  8631.     move.w    d6,d0
  8632.     ext.l    d0
  8633.     move.l    d0,(a0)+    ;mins
  8634.     swap    d6
  8635.     mulu    #50,d6
  8636.     add.l    d1,d6
  8637.     move.l    d6,(a0)        ;ticks
  8638. nospda    move.l    a2,d1    ;filename
  8639.     jsr    _LVODeviceProc(a6)
  8640.     tst.l    d0
  8641.     beq    DOSerr
  8642.     move.l    d0,packettask(a5)
  8643.     move.l    a2,a0
  8644.     lea    temp2buf(a5),a1
  8645.     move.l    a1,a3
  8646.     bsr    split_wild    No wildcard ! Only separates filename !
  8647.     move.l    a2,d1
  8648.     moveq    #ACCESS_READ,d2
  8649.     jsr    _LVOLock(a6)
  8650.     move.l    d0,d7
  8651.     beq    DOSerr
  8652.     move.l    d0,myArg2(a5)    ;BPTR lock
  8653.     move.l    a3,a0
  8654.     lea    tempbuf(a5),a1
  8655.     moveq    #-1,d0
  8656.     bsr    cpBSTR
  8657.     move.l    d0,myArg3(a5)    ;BSTR filename
  8658.     moveq    #ACTION_SET_DATE,d0
  8659.     move.l    d0,packettype(A5)
  8660.     bsr    sendpacket
  8661.     move.l    d7,d1
  8662.     jsr    _LVOUnLock(a6)
  8663.     bsr    PKTerr
  8664.     moveq    #RETURN_OK,d0
  8665.     rts
  8666.  
  8667. *************************
  8668. *    DISKCHANGE    *
  8669. *************************
  8670. diskchangez
  8671.     tst.l    parm2(a5)
  8672.     beq    too_less_args
  8673.     move.l    parm2(a5),d1    PARM2=DF0: etc
  8674.     jsr    _LVODeviceProc(a6)
  8675.     tst.l    d0
  8676.     beq    DOSerr
  8677.     move.l    d0,packettask(a5)
  8678.     bsr    changedisk
  8679.     moveq    #RETURN_OK,d0
  8680.     rts
  8681.  
  8682. ** USES task in packettask
  8683. changedisk
  8684.     bsr    clearArgs
  8685.     moveq    #ACTION_INHIBIT,d0
  8686.     move.l    d0,packettype(a5)
  8687.     moveq    #-1,d0    ;1?
  8688.     move.l    d0,myArg1(a5)
  8689.     bsr    sendpacket
  8690.     bsr    PKTerr
  8691.     clr.l    myArg1(a5)
  8692.     bsr    sendpacket
  8693.     bsr    PKTerr
  8694.     rts
  8695.  
  8696. *************************
  8697. *    LOCK        *
  8698. *************************
  8699. lockz    move.l    parm3(a5),a0
  8700.     moveq    #-1,d7
  8701.     bsr    CheckOnOff
  8702.     bne.s    .B
  8703.     moveq    #0,d7
  8704. .B    move.l    parm2(a5),d1    PARM2=DF0: etc
  8705.     beq    too_less_args
  8706.     jsr    _LVODeviceProc(a6)
  8707.     tst.l    d0
  8708.     beq    DOSerr
  8709.     move.l    d0,packettask(a5)
  8710.     bsr    clearArgs
  8711.     move.l    #ACTION_WRITE_PROTECT,d0
  8712.     move.l    d0,packettype(a5)
  8713.     move.l    d7,myArg1(a5)
  8714.     bsr    sendpacket
  8715.     bsr    PKTerr
  8716.     moveq    #RETURN_OK,d0
  8717.     rts
  8718.  
  8719. *************************
  8720. *    ALIAS        *    V2.9 uses Pool
  8721. *************************
  8722. ;LONG    alias_link
  8723. ;STRING    alias_name
  8724. ;STRING    alias_defn
  8725.  
  8726. aliasz    move.l    parm2(a5),d0
  8727.     beq    show_current_aliases
  8728.     tst.l    parm3(a5)
  8729.     beq    too_less_args
  8730.     move.l    d0,a0        A0=parm2
  8731.     bsr    check_if_alias_exits    update old alias ?
  8732.     beq    create_new_alias
  8733.     move.l    d0,a1        first delete old one
  8734.     move.l    (a1),d2        grab next alias pointer
  8735.     move.l    d1,a0        D1=prior alias
  8736.     move.l    d2,(a0)        skip over alias to delete
  8737.     move.l    parm2(a5),a0     and replace with new alias
  8738.  
  8739. create_new_alias    ;a0=name
  8740.     lea    tempbuf(a5),a3    create alias in tempbuf first
  8741.     move.l    a0,a1
  8742. .A    move.b    (a1)+,(a3)+    copy alias name
  8743.     bne.s    .A
  8744.     lea    CLIbuf(a5),a2    use CLIbuf, end in a1
  8745.     sub.l    CLIbufstart(a5),a2
  8746.     add.l    parm3(a5),a2
  8747.     cmp.b    #$22,-1(a2)
  8748.     bne.s    .D
  8749.     move.l    a2,a1
  8750. .E    move.b    (a1)+,d1
  8751.     beq.s    .D
  8752.     cmp.b    #$22,d1
  8753.     bne.s    .E
  8754.     clr.b    -1(a1)
  8755. .D    move.l    a2,a1
  8756. .F    move.b    (a1)+,(a3)+    copy alias definition
  8757.     bne.s    .F
  8758.     lea    tempbuf(a5),a2
  8759. ;alias in A2, A3 points to end
  8760. copy_new_alias
  8761.     move.l    alias_pool(a5),d0
  8762.     bne.s    .C
  8763.     bsr    CreatePool
  8764.     beq.s    .I
  8765.     move.l    d0,alias_pool(a5)
  8766. .C    move.l    d0,a0
  8767.     move.l    a3,d0
  8768.     sub.l    a2,d0
  8769.     addq.l    #4,d0        for link
  8770.     bsr    AllocPooled
  8771.     beq.s    .I
  8772.     move.l    d0,a0
  8773.     clr.l    (a0)+        clear link
  8774. .G    move.b    (a2)+,(a0)+    copy tempbuf to real alias position
  8775.     cmp.l    a3,a2
  8776.     blo.s    .G
  8777.     lea    first_alias(a5),a0
  8778.     move.l    a0,d1
  8779. .H    move.l    d1,a0
  8780.     move.l    (a0),d1        look for end of list
  8781.     bne.s    .H
  8782.     move.l    d0,(a0)        a0=last alias points to d0=new alias
  8783.     moveq    #RETURN_OK,d0
  8784.     rts
  8785. .I    moveq    #RETURN_ERROR,d0
  8786.     rts
  8787.  
  8788. check_if_alias_exits
  8789.     move.l    a0,-(sp)    A0=alias name
  8790.     lea    temp2buf(a5),a1
  8791.     bsr    cp_string
  8792.     bsr    search_alias
  8793.     move.l    (sp)+,a0
  8794.     rts
  8795.  
  8796. show_current_aliases
  8797.     bsr    pr_hide_cursor
  8798.     lea    first_alias(a5),a2
  8799. .C    move.l    (a2),d0
  8800.     beq.s    .A
  8801.     move.l    d0,a2        walk through list
  8802.     lea    4(a2),a1    alias name
  8803.     move.l    a1,a0
  8804. .D    tst.b    (a0)+        look for alias definition
  8805.     bne.s    .D
  8806.     bsr    pr_string
  8807.     bsr    pr_tab
  8808.     move.l    a0,a1
  8809.     bsr    pr_stringlf
  8810.     bra.s    .C
  8811. .A    moveq    #RETURN_OK,d0
  8812.     rts
  8813.  
  8814. *************************
  8815. *    UNALIAS        *    V2.9 uses Pool
  8816. *************************
  8817. ;NOTE: unsetting single aliases does not free memory
  8818. unaliasz
  8819.     lea    parm2(a5),a3
  8820.     move.l    (a3)+,d0
  8821.     beq    deallocate_aliases
  8822. .A    move.l    d0,a0
  8823.     bsr    check_if_alias_exits
  8824.     beq.s    .C
  8825.     move.l    d0,a1
  8826.     move.l    (a1),d2    grab next alias pointer
  8827.     move.l    d1,a0    D1=prior alias
  8828.     move.l    d2,(a0)    skip over alias to delete
  8829.     move.l    (a3)+,d0 and replace with new alias
  8830.     bne.s    .A
  8831.     moveq    #RETURN_OK,d0
  8832.     rts
  8833.  
  8834. .C    lea    temp2buf(a5),a2
  8835. pr_notfound    ;string in a2
  8836.     move.l    a2,a1
  8837.     bsr    pr_string
  8838.     lea    notfund(pc),a1
  8839.     bsr    pr_stringlf
  8840.     moveq    #RETURN_ERROR,d0
  8841.     rts
  8842.  
  8843. deallocate_aliases
  8844.     move.l    alias_pool(a5),a0
  8845.     bsr    DeletePool
  8846.     clr.l    first_alias(a5)
  8847.     clr.l    alias_pool(a5)
  8848.     moveq    #RETURN_OK,d0
  8849.     rts
  8850.  
  8851. *************************
  8852. *    RESIDENT    *    V2.0:uses the GLOBAL resident-list
  8853. *************************    (many things changed)
  8854. residentz    move.l    parm2(a5),d0    SEE IF ANY PARAMETERS TYPED
  8855.     beq    show_current_residents
  8856.     lea    parm2(a5),a3
  8857.     move.l    (a3),a0
  8858.     bsr    return_dash_option
  8859.     cmp.b    #'C',d0
  8860.     beq    kill_resi
  8861. next_resi    move.l    (a3)+,d0
  8862.     bne.s    .B
  8863.     moveq    #RETURN_OK,d0
  8864.     rts
  8865. .B    move.l    d0,a4        A4=parmName
  8866.     move.l    a3,-(sp)
  8867.     bsr    spaths2        SEARCH PATHS FOR THE COMMAND
  8868.     move.l    (sp)+,a3
  8869.     tst.l    d0
  8870.     beq    resi_not_found
  8871.     move.l    d0,-(sp)    push seglist
  8872.     move.l    a4,a0
  8873.     move.l    a4,a1
  8874.     bsr    rempath        SRC = DEST is OK
  8875.     bsr    search_res2    find if same name is on resi list
  8876.     move.l    (sp)+,d3
  8877.     move.l    d0,d1
  8878.     bne.s    .A
  8879.     bsr    create_resi
  8880.     bra.s    next_resi
  8881. .A    moveq    #1,d0
  8882.     cmp.l    resi_usecount(a0),d0
  8883.     bne.s    resi_inuse
  8884.     move.l    d0,resi_usecount(a0)
  8885.     move.l    d3,resi_seglist(a0)    new seglist
  8886.     jsr    _LVOUnLoadSeg(a6)    Unload old one with same name
  8887.     bra.s    next_resi
  8888.  
  8889. kill_resi    tst.l    (a3)+
  8890. .B    move.l    (a3)+,d0
  8891.     bne.s    .A
  8892.     moveq    #RETURN_OK,d0
  8893.     rts
  8894. .A    move.l    d0,a4
  8895.     move.l    a4,a0
  8896.     move.l    a4,a1
  8897.     bsr    rempath        SRC = DEST is OK
  8898.     bsr    search_res2    find if same name is on resi list
  8899.     move.l    d0,d1        gives d0,a0,d2
  8900.     beq.s    resi_not_found
  8901.     moveq    #1,d0
  8902.     cmp.l    resi_usecount(a0),d0
  8903.     bne.s    resi_inuse
  8904.     move.l    a0,a2
  8905.     move.l    d2,a0
  8906.     move.l    resi_link(a2),resi_link(a0)
  8907.     clr.l    resi_link(a2)
  8908.     jsr    _LVOUnLoadSeg(a6)    Unload old one with same name
  8909.     move.l    a2,d1
  8910.     lsr.l    #2,d1
  8911.     jsr    _LVOUnLoadSeg(a6)
  8912.     bra.s    .B
  8913.  
  8914. resi_not_found
  8915.     move.l    #205,d0
  8916.     bra.s    resi_error
  8917. resi_no_mem
  8918.     moveq    #103,d0
  8919.     bra.s    resi_error
  8920. resi_inuse
  8921.     move.l    #202,d0
  8922. resi_error
  8923.     move.l    dosbase(a5),a6
  8924.     bra    pr_galactic
  8925.  
  8926. create_resi        ;D3:SegList, A4:Name
  8927.     moveq    #resi_length,d0
  8928.     move.l    a4,a0
  8929. .A    addq.l    #1,d0    one more for lenght-byte
  8930.     tst.b    (a0)+
  8931.     bne.s    .A
  8932.     addq.l    #4,d0    4 more for segment-length
  8933.     addq.l    #7,d0    (7 more for and'ing needed by UnLoadSeg)
  8934.     moveq    #-4,d1
  8935.     and.l    d1,d0
  8936.     move.l    d0,d2
  8937.     bsr    iwantmem
  8938.     beq.s    resi_no_mem
  8939.     addq.l    #4,d0
  8940.     move.l    d0,a2        D0=addr of resi_list_node
  8941.     move.l    d2,-4(a2)    save segment-length
  8942.     bsr    do_forbid
  8943.     bsr    resi_hand
  8944.     move.l    d0,resi_link(a2)
  8945.     move.l    a2,d0
  8946.     lsr.l    #2,d0
  8947.     move.l    d0,(a0)
  8948.     moveq    #1,d0
  8949.     move.l    d0,resi_usecount(a2)
  8950.     move.l    d3,resi_seglist(a2)
  8951.     lea    resi_name(a2),a1
  8952.     move.l    a4,a0
  8953.     moveq    #-1,d0
  8954.     bsr    cpBSTR
  8955.     bsr    do_permit
  8956.     moveq    #0,d0
  8957.     rts
  8958.  
  8959. resi_hand    move.l    dl_Root(a6),a0
  8960.     move.l    rn_Info(a0),a0
  8961.     add.l    a0,a0
  8962.     add.l    a0,a0
  8963.     lea    di_NetHand(a0),a0    NetHand in A0
  8964.     move.l    (a0),d0        Start of Resi-List in D0
  8965.     rts
  8966.  
  8967. show_current_residents
  8968.     bsr    pr_hide_cursor
  8969.     lea    residetx(pc),a1
  8970.     bsr    pr_stringlf
  8971.     bsr    resi_hand
  8972.     beq    no_resis_to_show
  8973. .A    lsl.l    #2,d0
  8974.     move.l    d0,a3
  8975.     move.l    resi_usecount(a3),d0
  8976.     subq.l    #1,d0
  8977.     bsr    print10
  8978.     bsr    pr_space
  8979. ;    move.l    a3,d0
  8980. ;    bsr    printADR
  8981. ;    bsr    pr_space
  8982.     lea    resi_name(a3),a1
  8983.     moveq    #0,d3
  8984.     move.b    (a1)+,d3
  8985.     move.l    a1,d2
  8986.     move.l    outhandle(a5),d1
  8987.     beq.s    .B
  8988.     jsr    _LVOWrite(a6)
  8989.     bsr    pr_lf
  8990. .B    bsr    check_c
  8991.     bne.s    no_resis_to_show
  8992.     move.l    resi_link(a3),d0
  8993.     bne    .A
  8994. no_resis_to_show
  8995.     moveq    #RETURN_OK,d0
  8996.     rts
  8997.  
  8998. ******    Copy String from A0 to BSTR A1
  8999. cpBSTR    movem.l    d1-d2/a0-a2,-(sp)    max. Length-2 in D0
  9000.     lea    1(a1),a2
  9001.     moveq    #0,d2
  9002.     bra.s    .B
  9003. .A    move.b    d1,(a2)+
  9004.     addq.l    #1,d2
  9005. .B    move.b    (a0)+,d1
  9006.     dbeq    d0,.A
  9007.     clr.b    (a2)    ;NULL-end it
  9008.     move.b    d2,(a1)
  9009.     move.l    a1,d0
  9010.     lsr.l    #2,d0
  9011.     movem.l    (sp)+,d1-d2/a0-a2    D0 is BPTR to the BSTR
  9012.     rts
  9013.  
  9014.  
  9015. *********************************
  9016. *    RPN CALCULATOR        *
  9017. *********************************
  9018. evalz    lea    parm2(a5),a4
  9019.     move.l    sp,d5        remember the stack ptr
  9020. rpn_loop1    move.l    (a4)+,d1
  9021.     beq    show_rpn_result
  9022.     move.l    d1,a1
  9023.     tst.b    1(a1)
  9024.     bne    not_peek32
  9025.     lea    8(sp),a0
  9026.     cmp.l    a0,d5
  9027.     blo    not_poke32
  9028.  
  9029.     cmp.b    #'+',(a1)        +    ADD
  9030.     bne.s    not_add
  9031.     move.l    (sp)+,d0
  9032.     add.l    d0,(sp)
  9033.     bra.s    rpn_loop1
  9034. not_add    cmp.b    #'-',(a1)        -    SUBTRACT
  9035.     bne.s    not_sub
  9036.     move.l    (sp)+,d0
  9037.     sub.l    d0,(sp)
  9038.     bra.s    rpn_loop1
  9039.  
  9040. not_sub    cmp.b    #'*',(a1)        *    MULTIPLY
  9041.     bne.s    not_mult
  9042.     move.l    (sp)+,d0    last
  9043.     move.l    (sp)+,d1    2nd last
  9044.     bsr    mult_32x32
  9045.     move.l    d0,-(sp)
  9046.     bra.s    rpn_loop1
  9047. not_mult    cmp.b    #'/',(a1)    /    DIVIDE
  9048.     bne.s    not_div
  9049.     move.l    (sp)+,d1    last
  9050.     move.l    (sp)+,d0    2nd last
  9051.     tst.l    d1
  9052.     beq.s    rpn_error    no divide by zero
  9053.     bsr    div_32
  9054.     move.l    d0,-(sp)
  9055.     bra.s    rpn_loop1
  9056.  
  9057. not_div    cmp.b    #'&',(a1)        &    AND
  9058.     bne.s    not_and
  9059.     move.l    (sp)+,d0
  9060.     and.l    d0,(sp)
  9061. rpn_lp1    bra.s    rpn_loop1
  9062. not_and    cmp.b    #"!",(a1)        !    OR
  9063.     bne.s    not_or
  9064.     move.l    (sp)+,d0
  9065.     or.l    d0,(sp)
  9066.     bra.s    rpn_lp1
  9067. not_or    cmp.b    #'=',(a1)        =    POKE
  9068.     bne.s    not_poke32
  9069.     move.l    (sp)+,d1    get value
  9070.     move.l    (sp)+,d0    get addr
  9071.     and.b    #$fe,d0
  9072.     move.l    d0,a0
  9073.     move.l    (a0),-(sp)    peek it
  9074.     move.l    d1,(a0)        poke it
  9075.     bra.s    rpn_lp1
  9076. not_poke32
  9077.     cmp.b    #'?',(a1)        ?    PEEK
  9078.     bne.s    not_peek32
  9079.     move.l    (sp)+,d0    get addr
  9080.     cmp.l    sp,d5
  9081.     blo.s    rpn_error
  9082.     and.b    #$fe,d0
  9083.     move.l    d0,a0
  9084.     move.l    (a0),-(sp)
  9085.     bra.s    rpn_lp1
  9086.  
  9087. not_peek32
  9088.     bsr    convert_ASCII_to_num
  9089.     beq.s    rpn_error2
  9090.     move.l    d0,-(sp)
  9091.     bra.s    rpn_lp1
  9092. rpn_error2
  9093.     moveq    #115,d0
  9094.     bra.s    rpn_error1
  9095. rpn_error
  9096.     moveq    #-119,d0
  9097. rpn_error1
  9098.     move.l    d5,sp
  9099.     bsr    pr_DOSerr
  9100.     moveq    #RETURN_ERROR,d0
  9101.     rts
  9102.  
  9103. show_rpn_result
  9104.     lea    4(sp),a0
  9105.     cmp.l    a0,d5
  9106.     bne    rpn_error
  9107.     move.l    (sp),-(sp)        have result twice
  9108.     moveq    #RETURN_ERROR,d7    error on equal
  9109.     tst.l    (sp)
  9110.     beq.s    .B
  9111.     bpl.s    .C
  9112.     moveq    #RETURN_WARN,d7        warn on minus
  9113.     bra.s    .B
  9114. .C    moveq    #RETURN_OK,d7        ok on plus
  9115. .B    move.l    sp,a1
  9116.     lea    rpn_result_tx(pc),a0    print hex & dec
  9117.     tst.b    redirect_out(a5)    output redirected ?
  9118.     beq.s    .A
  9119.     moveq    #RETURN_OK,d7
  9120.     lea    rpn_res2(pc),a0    print only number
  9121. .A    bsr    new_print
  9122.     move.l    d5,sp
  9123.     move.l    d7,d0
  9124.     rts
  9125.  
  9126. div_32    movem.l    d2-d4,-(sp)    ;d0=d0/d1
  9127.     moveq    #0,d2
  9128.     moveq    #31,d4
  9129. _divu1    roxl.l    #1,d0    ; divident
  9130.     roxl.l    #1,d2    ; work accum
  9131.     cmp.l    d1,d2    ; cmp with divisor
  9132.     blo.s    _divu2
  9133.     sub.l    d1,d2
  9134.     dc.l    $003c0010    ;ori.b    #16,CCR    ;setx
  9135. _divu2    roxl.l    #1,d3    ; result
  9136.     dbf    d4,_divu1
  9137.     move.l    d3,d0
  9138.     move.l    d2,d1
  9139.     movem.l    (sp)+,d2-d4    ;result:d0 rest:d1
  9140.     rts
  9141.  
  9142.  
  9143. mult_32x32
  9144. * D1 = 32 bit, D0 = 32 bit (result)
  9145.     movem.l    d1-d3,-(sp)
  9146.     move.l    d0,d2
  9147.     move.l    d0,d3
  9148.     mulu    d1,d0    save intermediate result
  9149.     swap    d3
  9150.     mulu    d1,d3
  9151.     swap    d3
  9152.     clr.w    d3
  9153.     add.l    d3,d0
  9154.     swap    d1
  9155.     mulu    d1,d2
  9156.     swap    d2
  9157.     clr.w    d2
  9158.     add.l    d2,d0
  9159.     movem.l    (sp)+,d1-d3
  9160.     rts
  9161.  
  9162. * Convert null ending ASCII number(A1) to 32bit number in D0
  9163. * Return D1=0 if bad number (a1:current pos)
  9164. convert_ASCII_to_num    
  9165.     movem.l    d2/d3/a0,-(sp)
  9166.     moveq    #0,d3    SET POSITIVE
  9167.     moveq    #0,d1    RESET BASE
  9168. .A    cmp.b    #'^',(a1)
  9169.     bne.s    convnor
  9170.     lea    1(a1),a0
  9171.     bsr    readfile
  9172.     cmp.w    #NEWPRINTSIZE-2,d1
  9173.     bhs    conversion_finished
  9174.     move.l    d0,a0
  9175.     lea    NewPrintBuffer(a5),a1
  9176.     move.l    d1,d2
  9177.     subq.w    #1,d2
  9178. .B    move.b    (a0)+,(a1)+
  9179.     dbra    d2,.B
  9180.     clr.b    (a1)
  9181.     move.l    d0,a1
  9182.     move.l    d1,d0
  9183.     bsr    givemem
  9184.     lea    NewPrintBuffer(a5),a1
  9185. ;    bset    #0,d3
  9186.     bra.s    .A
  9187. convnor    moveq    #0,d0    RESET RESULT
  9188.     moveq    #0,d1    RESET BASE
  9189.     tst.b    (a1)
  9190.     beq    conversion_finished
  9191.     moveq    #LF,d1    SET THE BASE
  9192.     cmp.b    #'-',(a1)    negative sign
  9193.     bne.s    .A
  9194.     bset    #3,d3
  9195. .D    addq.l    #1,a1
  9196. .A    cmp.b    #'+',(a1)    positive sign
  9197.     beq.s    .D
  9198.     cmp.b    #'&',(a1)    for APTR (hex!) -> BPTR
  9199.     bne.s    .B
  9200.     addq.l    #1,a1
  9201.     bset    #1,d3
  9202.     moveq    #16,d1    SET RADIX16
  9203.     bra    same_base
  9204. .B    cmp.b    #'!',(a1)    for BPTR (hex!) -> APTR
  9205.     bne.s    .C
  9206.     addq.l    #1,a1
  9207.     bset    #2,d3
  9208.     moveq    #16,d1    SET RADIX16
  9209.     bra    same_base
  9210. .C    cmp.b    #'$',(a1)
  9211.     bne.s    other_base
  9212.     move.b    (a1)+,d2    DUMMY BUMP
  9213.     moveq    #16,d1    SET RADIX16
  9214.     bra    same_base
  9215.  
  9216. other_base
  9217.     cmp.b    #'%',(a1)
  9218.     bne.s    same_base
  9219.     move.b    (a1)+,d2
  9220.     moveq    #2,d1    SET RADIX2
  9221. same_base    moveq    #0,d2
  9222.     move.b    (a1)+,d2
  9223.     beq    conversion_finished
  9224.     bsr    convert_D2_to_num
  9225.     tst.l    d1
  9226.     beq.s    conversion_finished
  9227.     bsr    mult_32x32
  9228.     add.l    d2,d0
  9229.     bra    same_base
  9230. conversion_finished
  9231.     btst    #3,d3
  9232.     beq.s    .A
  9233.     neg.l    d0
  9234. .A    btst    #1,d3
  9235.     beq.s    .B
  9236.     lsr.l    #2,d0
  9237. .B    btst    #2,d3
  9238.     beq.s    .C
  9239.     lsl.l    #2,d0
  9240. .C    movem.l    (sp)+,d2/d3/a0
  9241.     tst.b    d1
  9242.     rts
  9243.     
  9244. convert_D2_to_num
  9245.     cmp.b    #'0',d2
  9246.     blo.s    bad_number
  9247.     cmp.b    #'9',d2
  9248.     bhi.s    check_hex
  9249.     sub.b    #'0',d2
  9250.     rts
  9251. check_hex    cmp.b    #16,d1
  9252.     bne.s    bad_number
  9253.     cmp.b    #'f',d2
  9254.     bhi.s    bad_number
  9255.     cmp.b    #'A',d2
  9256.     blo.s    bad_number
  9257.     cmp.b    #'F',d2
  9258.     bhi.s    check_upper_hex
  9259.     sub.b    #55,d2
  9260.     rts
  9261. check_upper_hex
  9262.     cmp.b    #'a',d2
  9263.     blo.s    bad_number
  9264.     sub.b    #87,d2
  9265.     rts
  9266. bad_number
  9267.     moveq    #0,d1    FLAG ERROR thru silly base
  9268.     rts
  9269.  
  9270. *********************************
  9271. *    MEMORY EXAMINE        *
  9272. *********************************
  9273. memexamz    clr.l    mem_offset_addr(a5)
  9274.     moveq    #8,d7
  9275.  
  9276.     move.l    parm2(a5),d0
  9277.     beq.s    show_mempage
  9278.     move.l    d0,a1
  9279.     bsr    convert_ASCII_to_num    convert 1st num
  9280.     beq.s    .A
  9281.     move.l    d0,mem_addr(a5)
  9282.  
  9283.     move.l    parm3(a5),d0
  9284.     beq.s    show_mempage
  9285.     move.l    d0,a1
  9286.     bsr    convert_ASCII_to_num    convert 2nd num
  9287. .A    beq    bad_number_error
  9288.     move.l    d0,d7            D7=2nd num
  9289.     sub.l    mem_addr(a5),d7
  9290.     lsr.l    #4,d7
  9291.     addq.l    #1,d7
  9292.  
  9293. show_mempage
  9294.     and.b    #$fe,mem_addr+3(a5)    MAKE SURE EVEN ADDRESS
  9295. shmem2    bsr    check_c
  9296.     bne    .A
  9297.     bsr    show_16_locs
  9298.     subq.l    #1,d7        D7=count
  9299.     bne.s    shmem2
  9300. .A    moveq    #RETURN_OK,d0
  9301.     rts
  9302.     
  9303. show_16_locs
  9304.     move.l    mem_addr(a5),a1
  9305.     lea    CLIbuf(a5),a3
  9306.     move.l    a3,a0
  9307.     moveq    #15,d0
  9308. sh_16_1    move.b    (a1)+,d1
  9309.     move.b    #'.',(a0)+
  9310.     move.b    d1,d2
  9311.     bclr    #7,d2
  9312.     cmp.b    #' ',d2
  9313.     blo.s    sh_16_2
  9314.     move.b    d1,-1(a0)
  9315. sh_16_2    dbra    d0,sh_16_1
  9316.     clr.b    (a0)
  9317.     move.l    a3,-(sp)        PUSH STRING ADDR
  9318.     move.l    -(a1),-(sp)    PUSH LAST BYTES
  9319.     move.l    -(a1),-(sp)
  9320.     move.l    -(a1),-(sp)
  9321.     move.l    -(a1),-(sp)    PUSH FIRST BYTES
  9322.     move.l    mem_addr(a5),d0
  9323.     sub.l    mem_offset_addr(a5),d0
  9324.     move.l    d0,-(sp)
  9325.     lea    mem_line(pc),a0
  9326.     lea    (sp),a1
  9327.     bsr    new_print
  9328.     movem.l    (sp)+,d0-d5    DUMMY
  9329.     add.l    #16,mem_addr(a5)
  9330.     rts
  9331.  
  9332. * ENTRY A0=FORMATSTRING A1=DATASTREAM.
  9333. new_print    ;v2.0 small data
  9334.     movem.l    d0-d3/a0-a3,-(sp)
  9335.     lea    NewPrintBuffer(a5),a3    ;V2.0 not on stack
  9336.     lea    KPutChar(pc),a2
  9337.     move.l    4.w,a6
  9338.     jsr    _LVORawDoFmt(a6)
  9339.     move.l    dosbase(a5),a6
  9340.     move.l    outhandle(a5),d1
  9341.     beq.s    .B
  9342.     lea    NewPrintBuffer(a5),a0
  9343.     move.l    a0,d2
  9344.     moveq    #-1,d3
  9345. .A    addq.l    #1,d3
  9346.     tst.b    (a0)+
  9347.     bne.s    .A
  9348.     jsr    _LVOWrite(a6)
  9349. .B    movem.l    (sp)+,d0-d3/a0-a3
  9350.     rts
  9351.  
  9352. KPutChar move.b    d0,(a3)+
  9353.     rts
  9354.  
  9355. ** SAVE STATS store current time in date mark, and current memory use in mem mark
  9356. save_mem_time
  9357.     movem.l    d0-d1/a0-a1,-(sp)
  9358.     clr.l    temp2(a5)
  9359.     btst    #FLcheck,Flags+3(a5)
  9360.     beq.s    .C
  9361.     move.l    4.w,a0
  9362.     tst.w    296(a0)        CPU better than 68000 ?
  9363.     bne.s    .A
  9364.     move.l    #1024,d0    no, store lower memory
  9365.     bsr    iwantmem
  9366.     move.l    d0,temp2(a5)
  9367.     beq.s    .A
  9368.     move.l    d0,a1
  9369.     sub.l    a0,a0        adress 0 to 1023
  9370.     move.l    #$C0DEDBAD,(a0)    Mungwall does the same
  9371.     move.l    #1024/4-1,d0
  9372. .B    move.l    (a0)+,(a1)+
  9373.     dbra    d0,.B
  9374. .A    lea    mem_mark(a5),a0
  9375.     bsr    memory_info    remember memory usage
  9376. .C    lea    date_mark(a5),a0
  9377.     bsr    get_time    remember this time
  9378.     movem.l    (sp)+,d0-d1/a0-a1
  9379.     rts
  9380.  
  9381. ** DISPLAY TIME ELAPSED SINCE LAST CALL TO SAVE TIME AND
  9382. **  ALSO CHANGE IN MEMORY AVAILABLE. EXPECTS RETURN CODE TO BE ABOVE RETURN
  9383. **  ADDRESS ON STACK ie 4(sp)
  9384. show_status
  9385.     lea    -34(sp),sp
  9386.     lea    (sp),a0        A0=time area
  9387.     move.l    Result2(a5),(a0)+    -4(a0) ioerr-result
  9388.     bsr    get_time    
  9389.     lea    date_mark(a5),a1
  9390.     move.l    ds_Tick(a0),d0
  9391.     sub.l    ds_Tick(a1),d0
  9392.     bpl.s    no_tick_carry
  9393.     add.l    #3000,d0
  9394.     subq.l    #1,ds_Minute(a0)
  9395. no_tick_carry
  9396.     move.l    d0,ds_Tick(a1)    store in datemark
  9397.     move.l    ds_Minute(a0),d0
  9398.     sub.l    ds_Minute(a1),d0
  9399.     move.l    d0,ds_Minute(a1)
  9400.     bsr    convert_time    A0=4+3 words of time
  9401. do_mem_deltas
  9402.     lea    14(a0),a0
  9403.     bsr    memory_info
  9404.     lea    mem_mark(a5),a1
  9405.     move.l    (a1),d0
  9406.     sub.l    d0,(a0)    subtract old from new    ;chip
  9407.     move.l    4(a1),d0
  9408.     sub.l    d0,4(a0)            ;fast
  9409.     move.l    8(a1),d0
  9410.     sub.l    d0,8(a0)            ;total
  9411.     lea    -12(a0),a1
  9412.     move.l    -18(a0),(a1)
  9413.     lea    stat_text(pc),a0
  9414.     bsr    new_print
  9415.     lea    34(sp),sp
  9416.     move.l    temp2(a5),d0    check low memory
  9417.     beq.s    .A
  9418.     move.l    d0,a1        show changes of low memory
  9419.     sub.l    a0,a0
  9420.     move.l    #1024/4-1,d0
  9421. .B    move.l    (a0)+,d1
  9422.     cmp.l    (a1)+,d1
  9423.     beq.s    .C
  9424.     movem.l    a0-a1,-(sp)
  9425.     move.l    -4(a0),-(sp)
  9426.     move.l    -4(a1),-(sp)
  9427.     move.l    a0,-(sp)
  9428.     subq.l    #4,(sp)
  9429.     move.l    sp,a1
  9430.     lea    lowmemtx(pc),a0    print the changes
  9431.     bsr    new_print
  9432.     lea    12(sp),sp
  9433.     movem.l    (sp)+,a0-a1
  9434. .C    dbra    d0,.B
  9435.     move.l    temp2(a5),a1
  9436.     move.l    #1024,d0
  9437.     bsr    givemem
  9438. .A    rts
  9439.  
  9440. *************************    
  9441. *    DATE/TIME    *
  9442. *************************
  9443. datez    lea    date_mark(a5),a2
  9444.     move.l    a2,a0
  9445.     bsr    get_time
  9446.     move.l    a2,a1
  9447.     lea    -14(sp),sp
  9448.     lea    (sp),a0
  9449.     bsr    convert_time
  9450.     tst.l    parm2(a5)
  9451.     beq.s    .A
  9452.     lea    parm2(a5),a0
  9453.     lea    (sp),a1
  9454.     bsr.s    settime
  9455.     lea    14(sp),sp
  9456.     bne.s    .B
  9457.     bsr    tset
  9458.     clr.l    parm2(a5)
  9459.     bra.s    datez    ;now print date/time
  9460. .A    lea    (sp),a1
  9461.     lea    time_text(pc),a0
  9462.     bsr    new_print
  9463.     lea    14(sp),sp
  9464.     moveq    #RETURN_OK,d0
  9465. .B    rts
  9466.  
  9467. settime    movem.l    d1-d4/a0-a4,-(sp)    V2.0
  9468.     move.l    a0,a4        ;a0=parameters
  9469.     move.l    a1,temp1(a5)    ;a1=date/time
  9470. settim    move.l    (a4)+,a0
  9471.     lea    temp2buf(a5),a2
  9472.     moveq    #2,d3
  9473. aa1    move.l    a0,a1
  9474.     bsr    gab
  9475.     move.b    d0,d4
  9476.     beq.s    bb1
  9477.     clr.b    -1(a0)
  9478.     cmp.b    #".",d0        ;day.month.year
  9479.     bne.s    dat2
  9480. bb1    bsr    convert_ASCII_to_num
  9481.     cmp.w    #99,d0    ;rough check
  9482.     bhi    muell
  9483.     move.w    d0,(a2)+
  9484.     tst.l    d1
  9485.     beq    muell
  9486.     tst.b    d4
  9487.     dbeq    d3,aa1
  9488. mull1    tst.w    d3
  9489.     bne    muell
  9490.     lea    temp2buf(a5),a2
  9491.     move.l    temp1(a5),a1
  9492.     moveq    #2,d3
  9493. .B    move.w    (a2)+,(a1)+
  9494.     dbra    d3,.B
  9495.     bra    oktt
  9496. aa2    move.l    a0,a1
  9497.     bsr    gab
  9498.     move.b    d0,d4
  9499.     beq.s    bb2
  9500.     clr.b    -1(a0)
  9501. dat2    cmp.b    #":",d0        ;hour:minute:second
  9502.     bne.s    dat3
  9503. bb2    bsr    convert_ASCII_to_num
  9504.     cmp.w    #99,d0
  9505.     bhi    muell
  9506.     move.w    d0,(a2)+
  9507.     tst.l    d1
  9508.     beq    muell
  9509.     tst.b    d4
  9510.     dbeq    d3,aa2
  9511. mull2    tst.w    d3
  9512.     bne    muell
  9513.     lea    temp2buf(a5),a2
  9514.     move.l    temp1(a5),a1
  9515.     lea    6(a1),a1
  9516.     moveq    #2,d3
  9517. .B    move.w    (a2)+,(a1)+
  9518.     dbra    d3,.B
  9519.     bra    oktt
  9520.     moveq    #2,d3
  9521. aa3    move.l    a0,a1
  9522.     bsr    gab
  9523.     move.b    d0,d4
  9524.     beq.s    bb3
  9525.     clr.b    -1(a0)
  9526. dat3    cmp.b    #"-",d0        ;month-day-year
  9527.     bne    muell
  9528. bb3    bsr    convert_ASCII_to_num
  9529.     cmp.w    #99,d0
  9530.     bhi    muell
  9531.     move.w    d0,(a2)+
  9532.     tst.l    d1
  9533.     beq    muell
  9534.     tst.b    d4
  9535.     dbeq    d3,aa3
  9536. mull3    tst.w    d3
  9537.     bne    muell
  9538.     lea    temp2buf(a5),a2
  9539.     move.l    temp1(a5),a1
  9540.     move.w    (a2)+,2(a1)
  9541.     move.w    (a2)+,(a1)
  9542.     move.w    (a2)+,4(a1)
  9543. oktt    tst.l    (a4)
  9544.     bne    settim
  9545.     lea    chaotab(pc),a0
  9546.     move.l    temp1(a5),a1
  9547.     lea    temp2buf(a5),a3
  9548.     moveq    #5,d0
  9549.     moveq    #0,d1
  9550. .A    move.b    (a0)+,d1
  9551.     move.w    0(a1,d1),d2
  9552.     move.b    d2,(a3)+
  9553.     dbra    d0,.A
  9554.     lea    temp2buf(a5),a3
  9555.     bsr    calcsec
  9556.     movem.l    (sp)+,d1-d4/a0-a4
  9557.     moveq    #RETURN_OK,d0
  9558.     rts    ;result in d5-d7
  9559.  
  9560. muell    lea    muell_tx(pc),a1
  9561.     bsr    pr_stringlf
  9562.     movem.l    (sp)+,d1-d4/a0-a4
  9563.     moveq    #RETURN_ERROR,d0
  9564.     rts
  9565.  
  9566. gab    move.b    (a0)+,d0
  9567.     cmp.b    #$30,d0
  9568.     blo.s    .A
  9569.     cmp.b    #$39,d0
  9570.     bls.s    gab
  9571. .A    cmp.b    #"%",d0    ;handle bin (that's fun !)
  9572.     beq.s    gab
  9573.     rts
  9574.  
  9575. ** GET TIME STORE DAYS,MINUTES,TICKS AT A0
  9576. get_time    move.l    a0,-(sp)
  9577.     move.l    a0,d1
  9578.     jsr    _LVODateStamp(a6)
  9579.     move.l    (sp)+,a0
  9580.     rts
  9581.  
  9582. ** ENTRY A0 pts to 7 words of storage, A1 pts to date stamp
  9583. ** send time to A0 --> 13(A0)
  9584. convert_time
  9585.     movem.l    d0-d3/a0-a2,-(sp)
  9586.     move.l    ds_Tick(a1),d0
  9587.     divu    #50,d0
  9588.     move.w    d0,4+6(a0)        seconds
  9589.     swap    d0
  9590.     asl.w    #1,d0
  9591.     move.w    d0,6+6(a0)        hundredths
  9592.     move.l    ds_Minute(a1),d0
  9593.     divu    #60,d0
  9594.     move.w    d0,0+6(a0)        hours
  9595.     swap    d0    
  9596.     move.w    d0,2+6(a0)        minutes
  9597.     move.l    ds_Days(a1),d0
  9598.     move.w    #365,d1        V2.0:year, day, month
  9599.     move.w    #77,d2
  9600. wdhj    addq.w    #1,d2
  9601.     sub.w    d1,d0
  9602.     bcs.s    mon
  9603.     move.w    d2,d3
  9604.     and.w    #3,d3
  9605.     bne.s    wdhj
  9606.     cmp.w    #100,d2
  9607.     blo.s    ork
  9608.     moveq    #1,d3
  9609.     addq.w    #1,d0
  9610.     sub.w    #100,d2
  9611. ork    subq.w    #1,d0
  9612.     bcc.s    wdhj
  9613.     addq.w    #1,d0
  9614. mon    add.w    d1,d0
  9615.     move.w    d2,4(a0)    year (lots of work)
  9616.     moveq    #0,d2
  9617.     lea    montab(pc),a2
  9618. wdhm    addq.w    #1,d2
  9619.     moveq    #0,d1
  9620.     move.b    (a2)+,d1
  9621.     sub.w    d1,d0
  9622.     bcs.s    tag
  9623.     cmp.w    #2,d2
  9624.     bne.s    wdhm
  9625.     move.w    4(a0),d3
  9626.     beq.s    wdhm
  9627.     and.w    #3,d3
  9628.     bne.s    wdhm
  9629.     subq.w    #1,d0
  9630.     bcc.s    wdhm
  9631.     addq.w    #1,d0
  9632. tag    add.w    d1,d0
  9633.     addq.w    #1,d0
  9634.     move.w    d2,2(a0)    month (i don't like february)
  9635.     move.w    d0,(a0)        day
  9636.     movem.l    (sp)+,d0-d3/a0-a2
  9637.     rts
  9638.  
  9639. montab    dc.b    31,28,31,30,31,30,31,31,30,31,30,31
  9640.  
  9641. *************************
  9642. *    STACK        *
  9643. *************************
  9644. stackz    move.l    CLIptr(a5),a4
  9645.     move.l    cli_DefaultStack(a4),d7
  9646.     lsl.l    #2,d7
  9647.     tst.l    parm2(a5)
  9648.     beq.s    show_stack
  9649.     move.l    parm2(a5),a1
  9650.     bsr    convert_ASCII_to_num
  9651.     beq    bad_number_error
  9652. stk_num_OK
  9653.     move.l    d0,d6
  9654.     cmpi.l    #1600,d6  ;allow 1600 bytes for DOS
  9655.     blt.s    stoosmall
  9656.     move.l    d6,d0
  9657.     bsr    iwantmem 
  9658.     beq.s    stoobig   
  9659.     move.l    d0,a1   
  9660.     move.l    d6,d0   
  9661.     bsr    givemem  
  9662.     
  9663.     lsr.l    #2,d6
  9664.     move.l    d6,cli_DefaultStack(a4)
  9665.     moveq    #RETURN_OK,d0
  9666.     rts
  9667. stoosmall
  9668.     move.l    #-148,d0
  9669.     bra    pr_galactic
  9670. stoobig
  9671.     bra    resi_no_mem
  9672. show_stack
  9673.     move.l    d7,-(sp)
  9674.     move.l    #-146,d0
  9675.     bsr    GetMessage
  9676.     lea    (sp),a1
  9677.     bsr    new_print
  9678.     move.l    (sp)+,d0
  9679.     moveq    #RETURN_OK,d0
  9680.     rts
  9681.  
  9682. ** CHECK STRING A0 IF ENDING IN :
  9683. ** RETURN EQ IF DOES END IN COLON
  9684. check_for_colon
  9685. .A    tst.b    (a0)+    MAKE SURE ENDS IN :
  9686.     bne.s    .A
  9687.     move.b    -2(a0),d0
  9688.     cmp.b    #':',d0
  9689.     rts
  9690.  
  9691. do_forbid    move.l    4.w,a6
  9692.     jsr    _LVOForbid(a6)
  9693.     move.l    dosbase(a5),a6
  9694.     rts
  9695. do_permit    move.l    4.w,a6
  9696.     jsr    _LVOPermit(a6)
  9697.     move.l    dosbase(a5),a6
  9698.     rts
  9699.     
  9700. *************************
  9701. *    ASSIGN         *
  9702. *************************
  9703. assignz    cmp.w    #36,kickver(a5)
  9704.     blo    assi13
  9705.     tst.l    parm2(a5)
  9706.     beq    assi13
  9707.     move.l    parm3(a5),d2
  9708.     beq    too_less_args
  9709.     move.l    parm2(a5),a2
  9710.     move.l    a2,a0
  9711.     bsr    check_for_colon
  9712.     bne.s    .G
  9713.     clr.b    -2(a0)    no colon-end
  9714. .G    lea    assignuse(pc),a1
  9715.     move.l    parm4(a5),d0
  9716.     bne.s    .B
  9717.     move.l    d2,a0
  9718.     bsr    CheckOpt
  9719.     beq.s    .C
  9720.     move.l    d2,d1        Assign LOCK
  9721.     moveq    #-2,d2
  9722.     jsr    _LVOLock(a6)
  9723.     move.l    d0,d7
  9724.     move.l    d0,d2
  9725.     beq    DOSerr
  9726.     move.l    a2,d1
  9727.     jsr    _LVOAssignLock(a6)
  9728.     tst.l    d0
  9729.     beq    DOSerrUL
  9730.     bra    .A
  9731. .C    move.l    a2,d1        Assign REMOVE
  9732.     moveq    #0,d2
  9733.     jsr    _LVOAssignLock(a6)
  9734.     tst.l    d0
  9735.     beq    DOSerr
  9736.     bra.s    .A
  9737.  
  9738. .B    move.l    d0,a0
  9739.     bsr    CheckOpt
  9740.     bne.s    .H
  9741.     move.l    d2,d1        Assign REMOVE part
  9742.     moveq    #-2,d2
  9743.     jsr    _LVOLock(a6)
  9744.     move.l    d0,d7
  9745.     move.l    d0,d2
  9746.     beq    DOSerr
  9747.     move.l    a2,d1
  9748.     jsr    _LVORemAssignList(a6)
  9749.     tst.l    d0
  9750.     beq    DOSerrUL
  9751.     bra.s    .A
  9752. .H    bsr    CheckOpt
  9753.     bne.s    .D
  9754.     move.l    d2,d1        Assign ADD
  9755.     moveq    #-2,d2
  9756.     jsr    _LVOLock(a6)
  9757.     move.l    d0,d7
  9758.     move.l    d0,d2
  9759.     beq    DOSerr
  9760.     move.l    a2,d1
  9761.     jsr    _LVOAssignAdd(a6)
  9762.     tst.l    d0
  9763.     beq    DOSerrUL
  9764.     bra.s    .A
  9765. .D    bsr    CheckOpt
  9766.     bne.s    .E
  9767.     move.l    a2,d1        Assign PATH
  9768.     jsr    _LVOAssignPath(a6)
  9769.     tst.l    d0
  9770.     beq    DOSerr
  9771.     bra.s    .A
  9772. .E    bsr    CheckOpt
  9773.     bne.s    .F
  9774.     move.l    a2,d1        Assign DEFER
  9775.     jsr    _LVOAssignLate(a6)
  9776.     tst.l    d0
  9777.     beq    DOSerr
  9778.     bra.s    .A
  9779. .F    lea    assignuse(pc),a1
  9780.     bsr    pr_stringlf
  9781. .A    moveq    #RETURN_OK,d0
  9782.     rts
  9783.  
  9784. assi13    bsr    do_forbid        FORBID
  9785.     bsr    get_first_devinfo
  9786.     tst.l    parm2(a5)
  9787.     beq    show_assigns
  9788.     tst.l    parm3(a5)
  9789.     beq    exit_assignf    ONLY TWO PARMS TYPED (NEED 3)
  9790.     move.l    parm2(a5),a0
  9791.     bsr    check_for_colon
  9792.     beq    assi14
  9793.     bsr    do_permit
  9794. no_col    move.l    #210,d0
  9795.     bra    pr_galactic
  9796.     
  9797. assi14    moveq    #dlt_directory,d1    CREATE/MODIFY ASSIGN ******
  9798.     bsr    find_next_assign
  9799.     tst.l    d0
  9800.     bne    no_more_dir_assigns
  9801.     move.l    a0,d5
  9802.     move.l    parm2(a5),a0    A0=assigned name[0]
  9803.     moveq    #0,d2
  9804.     move.b    (a1)+,d2        get char count
  9805. .A    move.b    (a1)+,d0
  9806.     move.b    (a0)+,d1
  9807.     beq.s    assi14
  9808.     subq.l    #1,d2
  9809.     bmi.s    .C
  9810.     bsr    compD1D0nocase
  9811.     beq.s    .A
  9812. .D    bra.s    assi14
  9813.  
  9814. .C    cmp.b    #':',d1    CHANGE EXISTING
  9815.     bne.s    .D
  9816.     bsr    do_permit        PERMIT
  9817.     move.l    d5,a2        GOT A MATCH
  9818.     moveq    #ACCESS_READ,d2
  9819.     move.l    parm3(a5),d1
  9820.     jsr    _LVOLock(a6)
  9821.     tst.l    d0
  9822.     beq    exit_assignp
  9823.     move.l    d0,a3
  9824.     bsr    do_forbid        FORBID
  9825.     move.l    dvi_Lock(a2),d4
  9826.     move.l    a3,dvi_Lock(a2)    new lock
  9827.     add.l    a3,a3
  9828.     add.l    a3,a3
  9829.     move.l    fl_Task(a3),dvi_Task(a2)
  9830.     clr.l    dvi_Handler(a2)
  9831.     clr.l    dvi_StackSize(a2)
  9832.     clr.l    dvi_Priority(a2)
  9833.     clr.l    dvi_Startup(a2)
  9834.     clr.l    dvi_SegList(a2)
  9835.     clr.l    dvi_GlobVec(a2)
  9836.     bsr    do_permit
  9837.     move.l    d4,d1
  9838.     jsr    _LVOUnLock(a6)
  9839.     bra    exit_assignp
  9840.     
  9841. no_more_dir_assigns
  9842.     bsr    do_permit        CREATE NEW ASSIGN
  9843.     moveq    #48,d0
  9844.     bsr    iwantcleanmem
  9845.     beq    exit_assignp
  9846.     move.l    d0,a4
  9847.     move.l    #48,(a4)+        save size byte
  9848.     move.l    parm2(a5),a0
  9849.     moveq    #4,d0    4+1 extra bytes for dos(nb: : is ignored)
  9850. .A    addq.l    #1,d0
  9851.     tst.b    (a0)+
  9852.     bne.s    .A
  9853.     move.l    d0,d3    D3=size+5+1    (block size|char_count|chars)
  9854.     bsr    iwantmem
  9855.     beq    rem_dvi
  9856.     move.l    d0,a3
  9857.     move.l    d0,d4        D4=string ptr
  9858.     move.l    d3,(a3)+        save size byte
  9859.     subq.l    #6,d3
  9860.     move.b    d3,(a3)+        save char_count
  9861.     move.l    parm2(a5),a0
  9862.     bra.s    .C
  9863. .B    move.b    d1,(a3)+        copy string to NAME
  9864. .C    move.b    (a0)+,d1
  9865.     cmp.b    #':',d1
  9866.     bne.s    .B
  9867.     clr.b    (a3)        ;NULL-ending V2.0
  9868.     addq.l    #4,d0
  9869.     lsr.l    #2,d0    convert to bstr
  9870.     move.l    d0,dvi_Name(a4)
  9871.     move.l    #dlt_directory,dvi_Type(a4)
  9872.     moveq    #ACCESS_READ,d2
  9873.     move.l    parm3(a5),d1
  9874.     jsr    _LVOLock(a6)
  9875.     tst.l    d0
  9876.     beq    rem_str
  9877.     move.l    d0,dvi_Lock(a4)
  9878.     lsl.l    #2,d0        x 4
  9879.     move.l    d0,a0
  9880.     move.l    fl_Task(a0),dvi_Task(a4)
  9881.     bsr    do_forbid
  9882.     bsr    get_first_devinfo    RETURNS A1 pts info substr, A2 pts 1st devinfo
  9883.     move.l    a2,dvi_Next(a4)
  9884.     move.l    a4,d0
  9885.     lsr.l    #2,d0
  9886.     move.l    d0,di_DevInfo(a1)    Insert new top of chain
  9887.     bsr    do_permit
  9888.     
  9889.     bra.s    exit_assignp
  9890. rem_str    move.l    d4,a1
  9891.     move.l    (a1),d0
  9892.     bsr    givemem
  9893. rem_dvi    lea    -4(a4),a1
  9894.     moveq    #48,d0
  9895.     bsr    givemem
  9896. exit_assignp
  9897.     moveq    #RETURN_OK,d0
  9898.     rts
  9899. exit_assignf
  9900.     bsr    do_permit
  9901.     moveq    #RETURN_OK,d0
  9902.     rts
  9903.     
  9904. * SHOW ASSIGNS    ALREADY IN FORBID STATE
  9905. show_assigns
  9906.     lea    -8(sp),sp
  9907.     move.l    a2,(sp)        0(sp)= BPTR of first devinfo
  9908.     move.l    #5000,d0
  9909.     bsr    iwantmem        allocate big block
  9910.     beq    asg_fail
  9911.     move.l    d0,a4        A4 = string block
  9912.     move.l    d0,a3
  9913.     add.l    #5000,a3    A3 = end of string block
  9914.     move.l    d0,4(sp)        4(sp) = string block
  9915.     lea    volume_tx(pc),a0    PRINT VOLUMES:
  9916.     bsr    copy_name
  9917.     moveq    #dlt_volume,d1
  9918. do_volumes
  9919. .E    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  9920.     tst.l    d0         TO THE BIG STRING
  9921.     bne.s    do_devices1
  9922.     bsr    copy_bstr
  9923.     move.b    #$20,(a4)+    seperate with spaces
  9924.     tst.l    dvi_Task(a0)
  9925.     bne.s    .H
  9926.     lea    unmounted_tx(pc),a0
  9927.     bsr    copy_name
  9928.     bra.s    .A
  9929. .H    move.b    #"[",(a4)+
  9930.     lea    mounted_tx(pc),a0
  9931.     bsr    copy_name
  9932. .A    move.b    #LF,(a4)+
  9933.     bra.s    .E
  9934. do_devices1
  9935.     move.l    (sp),a2        restart at first devinfo
  9936.     lea    device1_tx(pc),a0    PRINT DEVICES:
  9937.     bsr    copy_name
  9938.     lea    device3_tx(pc),a0
  9939.     bsr    copy_name
  9940. .B    moveq    #dlt_device,d1
  9941.     bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  9942.     tst.l    d0         TO THE BIG STRING
  9943.     bne.s    .A
  9944.     tst.l    dvi_Task(a0)
  9945.     bne.s    .B
  9946.     bsr    copy_bstr
  9947.     move.b    #$20,(a4)+    seperate with spaces
  9948.     move.b    #$20,(a4)+
  9949.     bra.s    .B
  9950. .A    move.b    #LF,(a4)+    linefeed at end
  9951. do_devices2
  9952.     move.l    (sp),a2        restart at first devinfo
  9953.     lea    device1_tx(pc),a0    PRINT DEVICES:
  9954.     bsr    copy_name
  9955.     lea    device2_tx(pc),a0
  9956.     bsr    copy_name
  9957. .B    moveq    #dlt_device,d1
  9958.     bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  9959.     tst.l    d0         TO THE BIG STRING
  9960.     bne.s    .A
  9961.     tst.l    dvi_Task(a0)
  9962.     beq.s    .B
  9963.     bsr    copy_bstr
  9964.     move.b    #$20,(a4)+    seperate with spaces
  9965.     move.b    #$20,(a4)+
  9966.     bra.s    .B
  9967. .A    move.b    #LF,(a4)+    linefeed at end
  9968. do_late
  9969.     move.l    (sp),a2
  9970.     lea    assign_tx(pc),a0    PRINT DIRECTORIES
  9971.     bsr    copy_name
  9972.     moveq    #dlt_late,d1
  9973. .B    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  9974.     tst.l    d0         TO THE BIG STRING
  9975.     bne.s    .A
  9976.     bsr    copy_bstr
  9977.     move.b    #":",(a4)+
  9978.     move.b    #9,(a4)+    seperate with tab
  9979.     move.b    #"<",(a4)+
  9980.     move.l    dvi_Handler(a0),a0
  9981.     bsr    copy_name
  9982.     move.b    #">",(a4)+
  9983.     move.b    #LF,(a4)+    linefeed at end
  9984.     bra.s    .B
  9985. .A    move.l    (sp),a2
  9986. do_nonbind
  9987.     moveq    #dlt_nonbind,d1
  9988. .B    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  9989.     tst.l    d0         TO THE BIG STRING
  9990.     bne.s    .A
  9991.     bsr    copy_bstr
  9992.     move.b    #":",(a4)+
  9993.     move.b    #9,(a4)+    seperate with tab
  9994.     move.b    #"[",(a4)+
  9995.     move.l    dvi_Handler(a0),a0
  9996.     bsr    copy_name
  9997.     move.b    #"]",(a4)+
  9998.     move.b    #LF,(a4)+    linefeed at end
  9999.     bra.s    .B
  10000. .A    move.l    (sp),a2
  10001. do_dirs        ;uses top of big mem block (end in a3)
  10002.     move.w    #-1,-(a3)    push negative
  10003. .G    moveq    #dlt_directory,d1
  10004.     bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  10005.     tst.l    d0         TO THE BIG STRING
  10006.     bne.s    .E
  10007.     clr.l    -(a3)        null-end locks
  10008.     cmp.w    #36,kickver(a5)
  10009.     blo.s    .A        OS1.3-: no assign add
  10010.     move.l    dvi_LockList(a0),d0    search locklist (assign add)
  10011.     beq.s    .A
  10012. .B    move.l    d0,a1
  10013.     move.l    4(a1),-(a3)    push locks
  10014.     move.l    (a1),d0
  10015.     bne.s    .B
  10016. .A    move.l    d2,-(a3)    push main lock
  10017.     clr.b    -(a3)        null-end name
  10018.     move.l    dvi_Name(a0),a1
  10019.     add.l    a1,a1
  10020.     add.l    a1,a1
  10021.     moveq    #0,d0
  10022.     move.b    (a1),d0        name-length
  10023.     btst    #0,d0
  10024.     bne.s    .C
  10025.     clr.b    -(a3)        for word-align
  10026. .C    add.l    d0,a1
  10027.     addq.l    #1,a1        a3=end of name
  10028.     bra.s    .D
  10029. .F    move.b    -(a1),-(a3)
  10030. .D    dbra    d0,.F
  10031.     bra.s    .G
  10032.  
  10033. .E    bsr    do_permit
  10034. get_nxt_lock
  10035.     cmp.b    #$ff,(a3)    check for end
  10036.     beq.s    .A
  10037.     move.l    a3,a0
  10038.     bsr    copy_name    copy assign-name
  10039. .B    tst.b    (a3)+        look for end
  10040.     bne.s    .B
  10041.     move.b    #9,(a4)+    copy tab
  10042.     move.l    a3,d0
  10043.     addq.l    #1,d0
  10044.     and.w    #$fffe,d0    word-align
  10045.     move.l    d0,a3
  10046.     move.l    (a3)+,d1    first lock
  10047.     beq.s    .F
  10048.     bra.s    .G
  10049. .C    move.l    (a3)+,d1
  10050.     beq.s    get_nxt_lock
  10051.     move.b    #9,(a4)+    other locks are assign adds
  10052.     move.b    #"+",(a4)+
  10053.     move.b    #" ",(a4)+
  10054. .G    move.l    d1,a0
  10055.     add.l    a0,a0
  10056.     add.l    a0,a0
  10057.     move.l    fl_Volume(a0),a0
  10058.     add.l    a0,a0
  10059.     add.l    a0,a0
  10060.     tst.l    dvi_Task(a0)    check for mounted
  10061.     bne.s    .E
  10062. .F    lea    unmounted_tx(pc),a0
  10063.     bsr    copy_name
  10064.     move.b    #LF,(a4)+
  10065.     bra.s    .C
  10066. .E    jsr    _LVODupLock(a6)    copy lock(D1) --> (D0)
  10067.     tst.l    d0
  10068.     beq.s    .F        could not dup lock
  10069.     move.l    a4,a0
  10070.     move.l    a3,-(sp)
  10071.     bsr    eval_full_path    write path to big block
  10072.     move.l    (sp)+,a3
  10073.     jsr    _LVOUnLock(a6)
  10074. .D    tst.b    (a4)+        look for end
  10075.     bne.s    .D
  10076.     move.b    #LF,-1(a4)    overwrite null or tab
  10077.     bra.s    .C
  10078. .A    clr.b    (a4)        null-end
  10079.  
  10080.     move.l    a4,d6
  10081.     subq.l    #1,d6
  10082.     move.l    4(sp),a4
  10083.     bsr    pr_hide_cursor
  10084.     bsr    pr_screen
  10085.     move.l    4(sp),a1
  10086.     move.l    #5000,d0
  10087.     bsr    givemem
  10088.     bra.s    asg_fail2
  10089. asg_fail    bsr    do_permit
  10090. asg_fail2    lea    8(sp),sp
  10091.     moveq    #RETURN_OK,d0
  10092.     rts
  10093.  
  10094.  
  10095. get_first_devinfo
  10096.     move.l    dl_Root(a6),a1
  10097.     move.l    rn_Info(a1),a1
  10098.     add.l    a1,a1
  10099.     add.l    a1,a1
  10100.     move.l    di_DevInfo(a1),a2    A2=BPTR to first devinfo
  10101.     rts
  10102.  
  10103. copy_name    move.b    (a0)+,(a4)+
  10104.     bne.s    copy_name
  10105.     lea    -1(a4),a4
  10106.     rts
  10107.  
  10108. **COPY BSTR FROM A1 TO A4, DONT NULL END
  10109. copy_bstr    moveq    #0,d0
  10110.     move.b    (a1)+,d0
  10111.     bra.s    .C
  10112. .B    move.b    (a1)+,(a4)+
  10113. .C    dbra    d0,.B
  10114.     rts
  10115.     
  10116. **ENTRY: D1=type ,A2=Bptr of devinfo, EXIT: A2=Bptr to next ,D0=0 if found
  10117. **EXIT: D2=lock, D1=type, A1 pts to string, A0 pts devinfo struct
  10118. find_next_assign
  10119. .A    add.l    a2,a2    FIND NEXT DEVINFO THAT MATCHES THE TYPE (D1)
  10120.     add.l    a2,a2        A2 pts to first devinfo structure
  10121.     move.l    a2,d0        tst.l    (a2)
  10122.     beq.s    .B
  10123.     move.l    a2,a0
  10124.     move.l    dvi_Name(a2),a1
  10125.     move.l    dvi_Lock(a2),d2
  10126.     move.l    dvi_Type(a2),d0
  10127.     move.l    (a2),a2
  10128.     cmp.l    d0,d1
  10129.     bne.s    .A
  10130.     add.l    a1,a1
  10131.     add.l    a1,a1
  10132.     moveq    #0,d0
  10133.     rts
  10134. .B    moveq    #1,d0
  10135.     rts
  10136.  
  10137. *************************
  10138. *    FAILAT         *
  10139. *************************
  10140. failatz    move.l    parm2(a5),d0
  10141.     beq.s    .A
  10142.     move.l    d0,a1
  10143.     bsr    convert_ASCII_to_num
  10144.     beq    bad_number_error
  10145.     move.l    CLIptr(a5),a0
  10146.     move.l    d0,cli_FailLevel(a0)
  10147.     bra.s    .B
  10148. .A    move.l    #-154,d0
  10149.     bsr    GetMessage
  10150.     move.l    CLIptr(a5),a1
  10151.     lea    cli_FailLevel(a1),a1
  10152.     bsr    new_print
  10153. .B    moveq    #RETURN_OK,d0
  10154.     rts
  10155.  
  10156. *************************
  10157. *    IF         *
  10158. *************************
  10159. ifz    move.b    #$ff,if_flag(a5)
  10160.     move.b    #$ff,if_condition(a5)    set FALSE
  10161.     lea    parm2(a5),a4
  10162.     moveq    #0,d4        not state
  10163. .C    move.l    (a4)+,d0
  10164.     beq    if_fail
  10165.     move.l    d0,a0
  10166.     lea    not_tx(pc),a1
  10167.     bsr    compare_strings
  10168.     bne.s    .B
  10169.     not.b    d4        set D4=FF if not
  10170.     bra    .C
  10171. .B    lea    exists(pc),a1
  10172.     bsr    compare_strings
  10173.     bne.s    try_warn    IF NOT AN EXISTS TYPE COMPARE
  10174.     move.l    (a4)+,d1
  10175.     beq    if_fail
  10176.     moveq    #0,d3        d3=0    doesnt exist
  10177.     moveq    #ACCESS_READ,d2
  10178.     jsr    _LVOLock(a6)
  10179.     tst.l    d0
  10180.     beq.s    save_state
  10181.     move.l    d0,d1
  10182.     jsr    _LVOUnLock(a6)
  10183.     not.b    d3        d3=ff    exists
  10184. save_state
  10185.     not.b    d3        d3=0    true
  10186.     eor.b    d4,d3
  10187.     move.b    d3,if_condition(a5)
  10188.     moveq    #RETURN_OK,D0
  10189.     RTS
  10190. try_warn    move.l    last_failcode(a5),d5
  10191.     moveq    #RETURN_WARN,d6
  10192.     lea    warn_tx(pc),a1    CHECK IF 'IF WARN'
  10193.     bsr    compare_strings
  10194.     bne    try_error
  10195. set_error_state
  10196.     moveq    #0,d3
  10197.     cmp.l    d6,d5
  10198.     bne    save_state
  10199.     not.b    d3
  10200.     bra    save_state
  10201. try_error    lea    error_tx(pc),a1
  10202.     bsr    compare_strings
  10203.     bne    try_fail
  10204.     moveq    #RETURN_ERROR,d6
  10205.     bra    set_error_state
  10206. try_fail    lea    fail_tx(pc),a1
  10207.     bsr    compare_strings
  10208.     bne    if_fail
  10209.     moveq    #RETURN_FAIL,d6
  10210.     bra    set_error_state
  10211. if_fail    not.b    if_flag(a5)    clear it
  10212.     bra    too_less_args
  10213.  
  10214. *************************
  10215. *    ASK         *
  10216. *************************
  10217. askz    bsr    echoz        print the parm same as echo does
  10218. rask    move.l    inhandle(a5),d1
  10219.     beq.s    .A
  10220.     lea    tempbuf(a5),a4    a4:tempbuf
  10221.     clr.b    (a4)
  10222.     move.l    a4,d2
  10223.     moveq    #120,d3
  10224.     jsr    _LVORead(a6)    read input
  10225.     tst.l    d0
  10226.     bmi.s    .A
  10227.     beq.s    .A
  10228.     move.l    a4,a0
  10229.     add.l    d0,a0
  10230.     subq.l    #1,a0
  10231.     clr.b    (a0)    Null-End
  10232.     tst.b    redirect_out(a5)    output redirected ?
  10233.     beq.s    .C
  10234.     move.l    a4,a1
  10235.     bsr    pr_string    repeat input
  10236.     bra    .A
  10237. .C    move.b    (a4),d1
  10238.     bset    #5,d1
  10239.     moveq    #RETURN_FAIL,d0
  10240.     cmp.b    #'f',d1        V2.0
  10241.     beq    .B
  10242.     moveq    #RETURN_ERROR,d0
  10243.     cmp.b    #'e',d1        V2.0
  10244.     beq    .B
  10245.     moveq    #RETURN_WARN,d0
  10246.     cmp.b    #'j',d1        V2.0
  10247.     beq    .B
  10248.     cmp.b    #'y',d1
  10249.     beq    .B
  10250. .A    moveq    #RETURN_OK,D0
  10251. .B    rts
  10252.  
  10253. *************************
  10254. *    WAIT         *
  10255. *************************
  10256. waitz    move.l    parm2(a5),d0
  10257.     beq    too_less_args
  10258.     move.l    d0,a1
  10259.     bsr    convert_ASCII_to_num
  10260.     beq    bad_number_error
  10261.     move.l    d0,d4
  10262.     lsl.l    #2,d4        d4*4
  10263.     add.l    d0,d4        d4:=d0*5 (d4*4+d4)
  10264. .C    bsr    check_c
  10265.     bne.s    .E
  10266.     moveq    #LF,d1        1/5 second
  10267.     jsr    _LVODelay(a6)
  10268.     subq.l    #1,d4
  10269.     bne.s    .C
  10270. .E    moveq    #RETURN_OK,D0
  10271.     RTS
  10272.  
  10273. *************************
  10274. *    QUIT         *
  10275. *************************
  10276. * only returns from script files.
  10277. quitz    tst.b    scflag(a5)
  10278.     bne.s    .A
  10279.     moveq    #RETURN_OK,D0
  10280.     RTS
  10281. .A    move.l    parm2(a5),d0
  10282.     beq    .B
  10283.     move.l    d0,a1
  10284.     bsr    convert_ASCII_to_num
  10285.     bne    .B
  10286.     bsr    bad_number_error
  10287. .B    move.l    d0,-(sp)
  10288.     bsr    kill_script    guarantee that script is dead
  10289.     move.l    (sp)+,d0
  10290.     rts
  10291.     
  10292. *************************
  10293. *    HTYPE         *
  10294. *************************
  10295. htypez    bsr    pr_hide_cursor
  10296.     tst.b    redirect_in(a5)
  10297.     beq.s    .C
  10298.     bsr    readstdin    read from inhandle
  10299.     bra.s    .D
  10300. .C    move.l    parm2(a5),d0
  10301.     beq    too_less_args
  10302.     move.l    d0,a0
  10303.     bsr    readfile    read from file
  10304. .D    move.l    d0,mem_addr(a5)
  10305.     move.l    d0,mem_offset_addr(a5)
  10306.     move.l    d1,temp1(a5)
  10307.     move.l    d1,d2
  10308.     add.l    d0,d1
  10309.     move.l    d1,d7        end marker
  10310.     move.l    parm3(a5),d0
  10311.     beq.s    .B
  10312.     move.l    d0,a1
  10313.     bsr    convert_ASCII_to_num
  10314.     beq.s    .B
  10315.     cmp.l    d0,d2
  10316.     bls.s    .B
  10317.     add.l    d0,mem_addr(a5)
  10318. .B    bsr    check_c
  10319.     bne    htype_end
  10320.     bsr    show_16_locs
  10321.     cmp.l    mem_addr(a5),d7
  10322.     bhi    .B
  10323. htype_end    move.l    mem_offset_addr(a5),a1
  10324.     move.l    temp1(a5),d0
  10325.     bsr    givemem
  10326.     moveq    #RETURN_OK,D0
  10327.     RTS
  10328.  
  10329. *************************
  10330. *    STRINGS     *
  10331. *************************
  10332. stringsz
  10333.     bsr    pr_hide_cursor
  10334.     lea    parm2(a5),a0
  10335.     tst.b    redirect_in(a5)
  10336.     bne.s    .A
  10337.     move.l    (a0),d2
  10338.     beq    too_less_args
  10339.     addq.l    #4,a0
  10340. .A    moveq    #7,d7        7=default number of characters
  10341.     move.l    (a0),d0
  10342.     beq    .C
  10343.     move.l    d0,a1
  10344.     bsr    convert_ASCII_to_num
  10345.     beq    bad_number_error
  10346.     move.l    d0,d7
  10347. .C    tst.b    redirect_in(a5)
  10348.     bne.s    .B
  10349.     move.l    d2,a0
  10350.     bsr    readfile    read from file
  10351.     bra.s    .D
  10352. .B    bsr    readstdin    read from inhandle
  10353. .D    move.l    d0,a4        A4=addr of file
  10354.     move.l    a4,a3
  10355.     move.l    d1,d6        D6=size of file
  10356.     add.l    d0,d1
  10357.     move.l    d1,d4        D4=max addr
  10358. str_next    bsr    check_c
  10359.     bne    kill_string_file
  10360.     moveq    #0,d5        D5=current string size
  10361.     move.l    a3,a2
  10362. valid_ch    cmp.l    a3,d4
  10363.     beq    string_fin
  10364.     move.b    (a3)+,d0
  10365.     cmp.b    #' ',d0
  10366.     blo.s    not_valid_char
  10367.     cmp.b    #$7f,d0
  10368.     bhi.s    not_valid_char
  10369.     addq.l    #1,d5
  10370.     bra    valid_ch
  10371. not_valid_char
  10372.     cmp.l    d7,d5
  10373.     blo    str_next
  10374.     bsr    write_my_string
  10375.     bra    str_next
  10376.  
  10377. string_fin
  10378.     cmp.l    d7,d5
  10379.     blo    kill_string_file
  10380.     bsr    write_my_string
  10381. kill_string_file
  10382.     move.l    a4,a1
  10383.     move.l    d6,d0
  10384.     bsr    givemem
  10385.     moveq    #RETURN_OK,D0
  10386.     RTS
  10387.     
  10388. write_my_string
  10389.     move.l    outhandle(a5),d1
  10390.     beq.s    .A
  10391.     move.l    a2,d2
  10392.     move.l    d5,d3
  10393.     jsr    _LVOWrite(a6)
  10394. .A    bra    pr_lf
  10395.  
  10396. *************************
  10397. *    FILENOTE    *        V2.0
  10398. *************************
  10399. filenotez
  10400.     move.l    parm3(a5),d2
  10401.     beq    too_less_args
  10402.     move.l    parm2(a5),d1
  10403.     jsr    _LVOSetComment(a6)
  10404.     tst.l    d0
  10405.     beq    DOSerr
  10406.     moveq    #RETURN_OK,d0
  10407.     rts
  10408.  
  10409. *************************
  10410. *    SEARCH        *    Searches a string in a file
  10411. *************************
  10412. searchz    bsr    pr_hide_cursor
  10413.     lea    parm2(a5),a2        V2.0
  10414.     tst.b    redirect_in(a5)
  10415.     beq.s    .G
  10416.     move.l    (a2),d7
  10417.     beq    too_less_args
  10418.     bsr    readstdin    read from inhandle
  10419.     bra.s    .F
  10420. .G    move.l    (a2)+,a0
  10421.     move.l    (a2),d7
  10422.     beq    too_less_args
  10423.     bsr    readfile    read from file
  10424. .F    move.l    d1,d5        d5:size of file
  10425.     move.l    d0,d6
  10426.     add.l    d1,d6
  10427.     move.l    d0,a2
  10428.     move.l    d0,a3        a3:start of file
  10429. .A    move.l    d7,a1        d7:search string
  10430.     move.l    d6,a0        d6:end of file
  10431.     bsr    searchSTR    a2:current searchpos
  10432.     cmp.b    #1,d0
  10433.     beq.s    .B
  10434.     move.l    a0,-(sp)
  10435.     move.l    d7,a0
  10436.     moveq    #-1,d4
  10437. .D    addq.l    #1,d4
  10438.     tst.b    (a0)+        length of searchstr.
  10439.     bne.s    .D
  10440.     move.l    a1,d2
  10441.     move.l    a2,d3
  10442.     sub.l    d2,d3
  10443.     beq.s    .C
  10444.     move.l    outhandle(a5),d1
  10445.     jsr    _LVOWrite(a6)    write part before searchstr.
  10446. .C    lea    farb3(pc),a1
  10447.     bsr    pr_string
  10448.     move.l    a2,d2
  10449.     move.l    d4,d3
  10450.     move.l    outhandle(a5),d1
  10451.     jsr    _LVOWrite(a6)    write searchstr.
  10452.     lea    farb1(pc),a1
  10453.     bsr    pr_string
  10454.     move.l    (sp)+,a0
  10455.     move.l    a2,d2
  10456.     add.l    d4,d2
  10457.     move.l    a0,d3
  10458.     sub.l    d2,d3
  10459.     beq.s    .E
  10460.     move.l    outhandle(a5),d1
  10461.     jsr    _LVOWrite(a6)    write part after searchstr.
  10462. .E    bsr    pr_lf
  10463.     addq.l    #1,a2
  10464.     bsr    check_c
  10465.     beq.s    .A
  10466. .B    move.l    d5,d0
  10467.     move.l    a3,a1
  10468.     bsr    givemem        free file
  10469. endse    moveq    #RETURN_OK,d0
  10470.     rts
  10471.  
  10472. * Searches for a string
  10473. * ENTRY:a1 points to the string to search for (ends in NULL)
  10474. *     a2 points to start position, a0 to end of file, a3 to start
  10475. * EXIT: a2  to found-position, a0 to NULL- or LF-end, a1 to LF-start
  10476. *    d0=1 not found, d0= found NULL-ended, d0=10 found LF-ended
  10477. searchSTR
  10478.     movem.l    d1-d7/a3-a5,-(sp)
  10479.     moveq    #"Z",d5
  10480.     moveq    #"A",d6
  10481.     moveq    #" ",d7
  10482.     move.l    a1,a4
  10483.     moveq    #0,d4
  10484. .B    move.b    (a4)+,d0
  10485.     beq.s    .D
  10486.     addq.l    #1,d4        count chars to search for
  10487.     cmp.b    d5,d0
  10488.     bhi.s    .A
  10489.     cmp.b    d6,d0
  10490.     blo.s    .A
  10491.     add.b    d7,d0
  10492.     move.b    d0,-1(a4)    lowercase them
  10493. .A    bra.s    .B
  10494. .D    move.b    (a1),d0
  10495.     cmp.b    dotchar(a5),d0
  10496.     bne.s    .C
  10497.     move.b    #LF,(a1)    begins with LineFeed
  10498. .C    move.l    a3,a5
  10499.     move.l    a0,d0        calc length of text
  10500.     sub.l    a2,d0
  10501.     sub.l    d4,d0
  10502.     move.l    d0,d4
  10503.     move.l    d4,d3
  10504.     swap    d3
  10505.     moveq    #0,d0
  10506.     moveq    #0,d2
  10507.     move.b    (a1),d2
  10508.     bra.s    seabeg
  10509. seastrt    move.b    (a2)+,d1
  10510.     cmp.b    d5,d1
  10511.     bhi.s    .E
  10512.     cmp.b    d6,d1
  10513.     blo.s    .E
  10514.     add.b    d7,d1
  10515. .E    cmp.b    d2,d1        compare first char
  10516.     bne.s    seabeg
  10517.  
  10518.     lea    1(a1),a3
  10519.     move.l    a2,a4
  10520. .B    move.b    (a3)+,d0
  10521.     beq.s    seafnd
  10522.     move.b    (a4)+,d1
  10523.     cmp.b    d5,d1
  10524.     bhi.s    .F
  10525.     cmp.b    d6,d1
  10526.     blo.s    .F
  10527.     add.b    d7,d1
  10528. .F    cmp.b    d0,d1        compare other chars
  10529.     beq.s    .B
  10530.  
  10531. seabeg    dbra    d4,seastrt
  10532.     dbra    d3,seastrt
  10533.     bra    seaend
  10534.  
  10535. seafnd    subq.l    #1,a2
  10536.     move.l    a2,a1
  10537. .D    cmp.l    a0,a4
  10538.     bhi    seaend
  10539.     move.b    (a4)+,d1    search end
  10540.     beq.s    .G
  10541.     cmp.b    #LF,d1
  10542.     bne.s    .D
  10543.     cmp.b    #LF,(a1)
  10544.     beq.s    .H
  10545. .F    cmp.l    a5,a1
  10546.     bls    .G
  10547.     move.b    -(a1),d0
  10548.     beq.s    .H
  10549.     cmp.b    #LF,d0        search beginning (if LF)
  10550.     bne.s    .F
  10551. .H    addq.l    #1,a1
  10552. .G    move.b    d1,d2
  10553.     lea    -1(a4),a0
  10554.     move.l    d2,d0
  10555.     movem.l    (sp)+,d1-d7/a3-a5
  10556.     rts
  10557. seaend    moveq    #1,d0
  10558.     movem.l    (sp)+,d1-d7/a3-a5
  10559.     rts
  10560.  
  10561. *****************
  10562. *    FAULT    *
  10563. *****************
  10564. faultz    move.l    parm2(a5),d0            V2.0
  10565.     beq    too_less_args
  10566.     move.l    d0,a1
  10567.     bsr    convert_ASCII_to_num
  10568.     beq    bad_number_error
  10569.     bsr    pr_DOSerr
  10570. .A    moveq    #RETURN_OK,d0
  10571.     rts
  10572.  
  10573. *************************
  10574. *    SETCLOCK    *
  10575. *************************
  10576. setclockz lea    $dc0000,a4    ;clockbase    V2.0
  10577.     move.b    1(a4),d4
  10578.     moveq    #75,d1
  10579.     jsr    _LVODelay(a6)
  10580.     cmp.b    1(a4),d4    ;secs changed ?
  10581.     beq.s    noclk
  10582.     lea    clk_tx(pc),a2
  10583.     move.l    parm2(a5),d0
  10584.     beq.s    .A
  10585.     move.l    d0,a0
  10586.     move.l    a2,a1
  10587.     bsr    CheckOpt
  10588.     beq    clkload
  10589.     lea    8(a2),a1
  10590.     bsr    CheckOpt
  10591.     beq.s    clksave
  10592. .A    move.l    a2,a1
  10593.     bsr    pr_stringlf
  10594.     moveq    #RETURN_ERROR,d0
  10595.     rts
  10596. noclk    lea    noclk_tx(pc),a0
  10597.     bsr    PrintError
  10598.     rts
  10599.  
  10600. clksave    lea    date_mark(a5),a2
  10601.     move.l    a2,a0
  10602.     bsr    get_time
  10603.     move.l    a2,a1
  10604.     lea    -14(sp),sp
  10605.     lea    (sp),a0
  10606.     bsr    convert_time
  10607.     move.b    61(a4),d0    ;reset clock
  10608.     or.b    #1,d0        ;(don't use bset or bclr !)
  10609.     move.b    d0,61(a4)
  10610.     move.b    #0,57(a4)
  10611.     move.b    #5,61(a4)
  10612.     move.b    #4,61(a4)
  10613.     move.b    53(a4),d0    ;hold clock
  10614.     or.b    #1,d0
  10615.     move.b    d0,53(a4)
  10616. clks    btst    #1,53(a4)
  10617.     bne.s    clks
  10618.     lea    (sp),a0
  10619.     lea    chaotab(pc),a1
  10620.     moveq    #1,d6
  10621.     moveq    #0,d1
  10622.     moveq    #5,d0
  10623. .A    move.b    (a1)+,d1
  10624.     moveq    #0,d2
  10625.     move.w    0(a0,d1),d2
  10626.     divu    #LF,d2
  10627.     swap    d2
  10628.     move.b    d2,0(a4,d6)
  10629.     swap    d2
  10630.     move.b    d2,4(a4,d6)
  10631.     addq.l    #8,d6
  10632.     dbra    d0,.A
  10633.     move.b    53(a4),d0
  10634.     and.b    #$0e,d0
  10635.     move.b    d0,53(a4)    ;run clock
  10636.     lea    14(sp),sp
  10637.     moveq    #RETURN_OK,d0
  10638.     rts
  10639.  
  10640. chaotab    dc.b    10,8,6,0,2,4
  10641.  
  10642. getclk    move.b    0(a4,d6),d1    ;Read realtimeclock
  10643.     move.b    4(a4,d6),d0    ;(adress in a4,offset in d6)
  10644.     addq.l    #8,d6
  10645.     and.w    #$f,d0
  10646.     and.w    #$f,d1
  10647.     mulu    #LF,d0
  10648.     add.w    d1,d0
  10649.     ext.l    d0    ;result
  10650.     rts
  10651.  
  10652.         ;load current time from realtime-clock
  10653. clkload    move.b    53(a4),d0
  10654.     or.b    #1,d0
  10655.     move.b    d0,53(a4)
  10656. clkw    btst    #1,53(a4)
  10657.     bne.s    clkw
  10658.     lea    -6(sp),sp
  10659.     lea    (sp),a3
  10660.     moveq    #5,d2
  10661.     moveq    #1,d6
  10662. .A    bsr    getclk
  10663.     move.b    d0,(a3)+
  10664.     dbra    d2,.A
  10665.     lea    (sp),a3
  10666.     bsr    calcsec        ;how many secs ?
  10667.     move.b    53(a4),d0
  10668.     and.b    #$0e,d0
  10669.     move.b    d0,53(a4)
  10670.     lea    6(sp),sp
  10671.     bsr    tset        ;give it to system
  10672.     moveq    #RETURN_OK,d0
  10673.     rts
  10674.  
  10675. calcsec    moveq    #0,d7        ;a3->points to 6 bytes of date/time
  10676.     moveq    #1,d6                    V2.0
  10677.     move.b    (a3)+,d7    ;sec (collect secs in d7)
  10678.     moveq    #0,d0
  10679.     move.b    (a3)+,d0    ;min
  10680.     mulu    #smin,d0
  10681.     add.l    d0,d7
  10682.     moveq    #0,d0
  10683.     move.b    (a3)+,d0    ;std
  10684.     mulu    #sst,d0
  10685.     add.l    d0,d7
  10686.     moveq    #0,d0
  10687.     move.b    (a3)+,d0    ;tag
  10688.     subq.l    #1,d0
  10689.     move.l    d0,d5        ;collect days in d5
  10690.     moveq    #0,d2
  10691.     move.b    (a3)+,d2    ;monat
  10692.     lea    montab(pc),a0
  10693.     moveq    #0,d3
  10694.     move.b    (a3)+,d3    ;jahr
  10695.     move.l    d3,d0
  10696.     and.w    #3,d0
  10697.     bne.s    nosj
  10698.     move.b    #29,1(a0)    ;change montab
  10699. nosj    subq.l    #2,d2
  10700.     bmi.s    jan
  10701. madd    moveq    #0,d0
  10702.     move.b    0(a0,d2),d0
  10703.     add.w    d0,d5
  10704.     dbra    d2,madd
  10705. jan    cmp.b    #78,d3
  10706.     beq.s    tset
  10707.     subq.l    #1,d3
  10708.     moveq    #0,d1
  10709. jadd    add.w    #tjahr,d5
  10710.     move.l    d3,d0
  10711.     and.w    #3,d0
  10712.     bne.s    nosj2
  10713.     addq.l    #1,d5
  10714. nosj2    cmp.b    #78,d3
  10715.     dbeq    d3,jadd
  10716.     move.b    #28,1(a0)
  10717.     move.l    #stag,d1
  10718.     move.l    d5,d0
  10719.     bsr    mult_32x32
  10720.     move.l    d7,d6        ;d6=secs, d5=days
  10721.     add.l    d0,d7        ;d7=all seconds since 1.1.78
  10722.     rts
  10723.  
  10724. clrio    lea    io_Message(a5),a1    ;initialisiert IO-Request  V2.0
  10725.     move.l    a1,a0
  10726.     moveq    #$2f,d0
  10727. clst3    clr.b    (a0)+
  10728.     dbra    d0,clst3
  10729.     move.b    #5,io_Message+8(a5)
  10730.     move.l    thistask(a5),a0
  10731.     lea    pr_MsgPort(a0),a0
  10732.     move.l    a0,io_Message+14(a5)
  10733.     move.w    #$30,io_Message+18(a5)
  10734.     rts        ;a1:IO-Request a0:Msg-Port
  10735.  
  10736. tset    move.l    4.w,a6        ;set time with timer-device (secs in d7)
  10737.     bsr    clrio                V2.0
  10738.     move.w    #40,io_Message+18(a5)
  10739.     lea    timdev(pc),a0
  10740.     moveq    #1,d0
  10741.     moveq    #0,d1
  10742.     jsr    _LVOOpenDev(a6)
  10743.     tst.l    d0
  10744.     bne    tmfehl
  10745.     lea    io_Message(a5),a1
  10746.     move.w    #11,io_Command(a5)
  10747.     clr.w    io_Flags(a5)
  10748.     move.l    d7,tv_secs(a5)
  10749.     clr.l    tv_micro(a5)
  10750.     jsr    _LVODoIO(a6)
  10751.     tst.l    d0
  10752. ;    bne.s    tmfehl    ;better leave out
  10753.     lea    io_Message(a5),a1
  10754.     clr.l    io_Command(a5)
  10755.     jsr    _LVOCloseDev(a6)
  10756. tmfehl    move.l    dosbase(a5),a6
  10757.     rts
  10758.  
  10759. smin    equ    60
  10760. sst    equ    60*smin
  10761. stag    equ    24*sst
  10762. tjahr    equ    365
  10763.  
  10764.  
  10765. *************************
  10766. *    SHOW        *
  10767. *************************
  10768. soffs    dc.w    378,336,350,364,322,392,532
  10769.  
  10770. showz    bsr    pr_hide_cursor        V2.0
  10771.     move.l    parm2(a5),d0
  10772.     beq    sdft
  10773.     move.l    d0,a0
  10774.     move.b    (a0),d1
  10775.     bset    #5,d1
  10776.     cmp.b    #"t",d1
  10777.     beq    shtask
  10778.     cmp.b    #"v",d1
  10779.     beq    shvec
  10780.     lea    styp(pc),a0
  10781.     moveq    #6,d0    ;7 Lists
  10782. .D    cmp.b    0(a0,d0.w),d1
  10783.     dbeq    d0,.D
  10784.     move.w    d0,d7
  10785.     bmi    sdft
  10786.     lea    show_tx(pc),a1
  10787.     cmp.w    #2,d7
  10788.     bhi.s    .C
  10789.     lea    show2_tx(pc),a1
  10790. .C    bsr    pr_stringlf
  10791.     bsr    do_forbid
  10792.     add.w    d0,d0
  10793.     lea    soffs(pc),a0
  10794.     move.w    0(a0,d0.w),d0
  10795.     move.l    4.w,a4
  10796.     move.l    0(a4,d0.w),a1
  10797. ;    move.l    8(a4,d0.w),a2
  10798.     lea    tempbuf(a5),a3
  10799. .A    tst.l    (a1)
  10800.     beq.s    .B
  10801.     move.l    a1,(a3)+
  10802.     move.l    (a1),a1
  10803.     bra.s    .A
  10804. .B    clr.l    (a3)
  10805.     bsr    do_permit
  10806.     lea    tempbuf(a5),a3
  10807. da    tst.l    (a3)
  10808.     beq    sdf
  10809.     move.l    (a3)+,a2
  10810.     move.l    10(a2),-(sp)
  10811.     lea    shform(pc),a0
  10812.     cmp.w    #2,d7
  10813.     bhi.s    .E
  10814.     lea    shform2(pc),a0
  10815.     move.w    22(a2),-(sp)
  10816.     move.w    20(a2),-(sp)
  10817. .E    move.b    9(a2),d0
  10818.     ext.w    d0
  10819.     move.w    d0,-(sp)
  10820.     move.l    a2,-(sp)
  10821.     lea    (sp),a1
  10822.     bsr    new_print
  10823.     lea    10(sp),sp
  10824.     cmp.w    #2,d7
  10825.     bhi.s    da
  10826.     addq.l    #4,sp
  10827.     bra.s    da
  10828. sdft    lea    shuse_tx(pc),a1
  10829.     bsr    pr_stringlf
  10830.     moveq    #RETURN_BAD,d0
  10831.     rts
  10832. sdf    moveq    #RETURN_OK,d0
  10833.     rts
  10834.  
  10835. shtask    lea    tempbuf(a5),a3    enough for 96 tasks
  10836.     move.l    4.w,a6
  10837.     jsr    _LVOForbid(a6)
  10838.     lea    420(a6),a0
  10839.     move.l    (a0),a1
  10840. .A    tst.l    (a1)
  10841.     beq.s    .B
  10842.     move.l    a1,(a3)+
  10843.     move.l    (a1),a1
  10844.     bra.s    .A
  10845. .B    lea    406(a6),a0
  10846.     move.l    (a0),a1
  10847. .C    tst.l    (a1)
  10848.     beq.s    .D
  10849.     move.l    a1,(a3)+
  10850.     move.l    (a1),a1
  10851.     bra.s    .C
  10852. .D    move.l    276(a6),(a3)+
  10853.     clr.l    (a3)
  10854.     jsr    _LVOPermit(a6)
  10855.     move.l    dosbase(a5),a6
  10856.     lea    shta_tx(pc),a1
  10857.     bsr    pr_stringlf
  10858.     lea    tempbuf(a5),a3
  10859. prsht    move.l    (a3)+,a2
  10860.     move.l    10(a2),-(sp)
  10861.     move.l    #$00540061,d0    Task
  10862.     cmp.b    #13,LN_TYPE(a2)
  10863.     bne.s    .C
  10864.     move.l    #$00500072,d0    Process
  10865.     cmp.w    #36,kickver(a5)
  10866.     blo.s    .C
  10867.     tst.l    pr_ExitCode(a2)
  10868.     beq.s    .C
  10869.     move.l    #$00500021,d0    Process with exit code
  10870. .C    move.l    d0,-(sp)
  10871.     move.l    tc_SigWait(a2),-(sp)
  10872.     moveq    #0,d0
  10873.     move.b    tc_State(a2),d0
  10874.     lea    ttyp(pc),a0
  10875.     bra.s    .A
  10876. .B    tst.b    (a0)+
  10877.     bne.s    .B
  10878. .A    dbra    d0,.B
  10879.     move.l    a0,-(sp)
  10880.     move.b    LN_PRI(a2),d0
  10881.     ext.w    d0
  10882.     move.w    d0,-(sp)
  10883.     move.l    a2,-(sp)
  10884.     lea    (sp),a1
  10885.     lea    shtaform(pc),a0
  10886.     bsr    new_print        Print it
  10887.     lea    22(sp),sp
  10888.  
  10889.     cmp.b    #13,LN_TYPE(a2)
  10890.     bne.s    snocli
  10891.     move.l    pr_CLI(a2),d1
  10892.     beq.s    snocli
  10893.     lsl.l    #2,d1    ;cli-process
  10894.     move.l    d1,a4
  10895.     lea    null(pc),a1
  10896.     move.l    a1,-(sp)
  10897.     move.l    pr_COS(a2),d1
  10898.     cmp.l    cli_StandardOutput(a4),d1
  10899.     beq.s    .J
  10900.     lea    bigger(pc),a0
  10901.     move.l    a0,(sp)
  10902. .J    move.l    a1,-(sp)
  10903.     move.l    pr_CIS(a2),d1
  10904.     cmp.l    cli_StandardInput(a4),d1
  10905.     beq.s    .G
  10906.     lea    smaller(pc),a0
  10907.     move.l    a0,(sp)
  10908. .G    move.l    a1,-(sp)
  10909.     move.l    cli_CommandName(a4),d1
  10910.     beq.s    .H
  10911.     lsl.l    #2,d1
  10912.     move.l    d1,a0
  10913.     lea    temp2buf(a5),a1        BSTR !
  10914.     move.l    a1,(sp)
  10915.     moveq    #0,d1
  10916.     move.b    (a0)+,d1
  10917.     bra.s    .E
  10918. .F    move.b    (a0)+,(a1)+
  10919. .E    dbra    d1,.F
  10920.     clr.b    (a1)
  10921. .H    move.l    pr_TaskNum(a2),-(sp)
  10922.     lea    null(pc),a1
  10923.     move.l    a1,-(sp)
  10924.     tst.l    cli_Background(a4)    background ?
  10925.     beq.s    .I
  10926.     lea    backcli(pc),a1
  10927.     move.l    a1,(sp)
  10928. .I    lea    proform(pc),a0
  10929.     lea    (sp),a1
  10930.     bsr    new_print        Print CLI-Add
  10931.     lea    20(sp),sp
  10932. snocli    bsr    pr_lf
  10933.     tst.l    (a3)
  10934.     bne    prsht    ;at least one task
  10935. shtok    moveq    #RETURN_OK,D0
  10936.     rts
  10937.  
  10938. shvec    move.l    4.w,a0
  10939.     move.l    eb_KickCheckSum(a0),-(sp)
  10940.     move.l    eb_ColdCapture(a0),-(sp)
  10941.     move.l    eb_KickTagPtr(a0),-(sp)
  10942.     move.l    eb_CoolCapture(a0),-(sp)
  10943.     move.l    eb_KickMemPtr(a0),-(sp)
  10944.     move.l    eb_WarmCapture(a0),-(sp)
  10945.     lea    (sp),a1
  10946.     lea    vec_line(pc),a0
  10947.     bsr    new_print
  10948.     moveq    #RETURN_ERROR,d0
  10949.     moveq    #5,d1
  10950.     move.l    sp,a0
  10951. .A    tst.l    (a0)+
  10952.     bne.s    .B
  10953.     dbra    d1,.A
  10954.     moveq    #RETURN_OK,d0
  10955. .B    lea    6*4(sp),sp    get rid of trash
  10956.     rts
  10957.  
  10958.  
  10959. *************************
  10960. *    MemClock    *    V2.0
  10961. *************************
  10962.  
  10963. ckstackSIZE    equ    2000
  10964. cktask    equ    0        ;Task-Struct
  10965. ckport    equ    cktask+92    ;MsgPort
  10966. ckstack    equ    ckport+34    ;Stack
  10967. ckustack equ    ckstack+ckstackSIZE
  10968. ckdos    equ    ckustack    ;DOSBase
  10969. ckint    equ    ckdos+4        ;Intuitionbase
  10970. ckitxt    equ    ckint+4        ;IntuiTextStruct
  10971. ckdate    equ    ckitxt+20    ;DateStamp
  10972. ckrawdo    equ    ckdate+12    ;DataStream
  10973. ckcook    equ    ckrawdo+6+8    ;Formatted String
  10974. ckwint    equ    ckcook+40    ;Table of all Windows
  10975. cknum    equ    ckwint+20*4    ;Number of Windows
  10976. ckalarm    equ    cknum+4        ;Alarm-Time
  10977. ckpad    equ    ckalarm+8
  10978. cksize    equ    ckpad+2
  10979.  
  10980. mlnode    equ    0        ;Memory-List
  10981. mlnum    equ    mlnode+14
  10982. mladdr    equ    mlnum+2
  10983. mllen    equ    mladdr+4
  10984. mlsize    equ    mllen+4
  10985.  
  10986. memclkz    move.l    parm2(a5),d0
  10987.     beq    too_less_args
  10988.     move.l    d0,a0
  10989.     move.b    (a0),d0
  10990.     bset    #5,d0
  10991.     cmp.b    #"a",d0    ;alarm
  10992.     beq    clkalm
  10993.     bsr    CheckOnOff
  10994.     beq    clkoff
  10995.  
  10996. clkon    move.b    #1,memclk_flag(a5)    switch it on
  10997.     move.l    4.w,a6
  10998.     lea    clktask+1(pc),a1
  10999.     jsr    _LVOFindTask(a6)
  11000.     move.l    d0,a4
  11001.     tst.l    d0
  11002.     beq.s    .A    ;not already running
  11003.     bsr    winclk
  11004. .B    moveq    #RETURN_OK,d0
  11005.     rts
  11006. .A    move.l    #cksize,d0
  11007.     move.l    #1+1<<16,d1
  11008.     jsr    _LVOAllocMem(a6)
  11009.     tst.l    d0
  11010.     beq.s    .B
  11011.     move.l    d0,a4
  11012.     move.w    #$0104,cktask+8(a4)    ;type/pri
  11013.     lea    clktask+1(pc),a0
  11014.     move.l    a0,cktask+10(a4)    ;name
  11015.     lea    ckstack(a4),a0
  11016.     lea    ckustack(a4),a1
  11017.     move.l    a1,cktask+54(a4)    ;SPreg
  11018.     move.l    a0,cktask+58(a4)    ;lowerstack
  11019.     move.l    a1,cktask+62(a4)    ;upperstack
  11020.     move.l    a4,ckport+16(a4)    ;sigtask
  11021.     lea    ckport+20+4(a4),a0
  11022.     move.l    a0,ckport+20(a4)
  11023.     lea    ckport+20(a4),a0
  11024.     move.l    a0,ckport+20+8(a4)
  11025.     move.l    #mlsize,d0
  11026.     move.l    #1+1<<16,d1
  11027.     jsr    _LVOAllocMem(a6)
  11028.     tst.l    d0
  11029.     beq.s    .B
  11030.     move.l    d0,a2
  11031.     moveq    #1,d0
  11032.     move.w    d0,mlnum(a2)
  11033.     move.l    a4,mladdr(a2)
  11034.     move.l    #cksize,mllen(a2)
  11035.     lea    mlnode(a2),a0
  11036.     lea    cktask+78(a4),a1
  11037.     move.l    a0,-4(a1)
  11038.     move.l    a0,4(a1)
  11039.     move.l    a1,(a0)
  11040.     move.l    a1,4(a0)
  11041.     move.l    dosbase(a5),ckdos(a4)
  11042.     move.l    intuibase(a5),ckint(a4)
  11043.     bsr    winclk
  11044.     move.l    4.w,a6
  11045.     move.l    a4,a1
  11046.     lea    clkstart(pc),a2
  11047.     moveq    #0,d0
  11048.     move.l    d0,a3
  11049.     jsr    _LVOAddTask(a6)
  11050.     move.l    dosbase(a5),a6
  11051.     moveq    #RETURN_OK,d0
  11052.     rts
  11053.  
  11054. winclk    bsr    findwin        check if window already exists,
  11055.     tst.w    d1        otherwise move window in table
  11056.     bpl.s    .C
  11057.     moveq    #19,d1
  11058. .B    tst.l    (a1)+
  11059.     dbeq    d1,.B
  11060.     bne.s    .C
  11061.     move.l    d0,-4(a1)
  11062. .C    rts
  11063.  
  11064. findwin
  11065.     move.l    dosbase(a5),a6
  11066.     move.l    windowptr(a5),d0
  11067.     beq.s    .B
  11068.     lea    ckwint(a4),a0
  11069.     move.l    a0,a1
  11070.     moveq    #19,d1
  11071. .A    cmp.l    (a0)+,d0
  11072.     dbeq    d1,.A
  11073. .B    rts
  11074.  
  11075. clkoff    clr.b    memclk_flag(a5)    switch it off
  11076. clkof2    move.l    a4,-(sp)
  11077.     move.l    4.w,a6
  11078.     lea    clktask+1(pc),a1
  11079.     jsr    _LVOFindTask(a6)
  11080.     move.l    d0,a4
  11081.     tst.l    d0
  11082.     beq.s    .A
  11083.     bsr    findwin
  11084.     tst.w    d1
  11085.     bmi.s    .A
  11086.     moveq    #0,d0
  11087.     move.l    d0,-4(a0)
  11088. .A    move.l    (sp)+,a4
  11089.     move.l    windowptr(a5),d0
  11090.     beq.s    .C
  11091.     move.l    d0,a0
  11092.     move.l    intuibase(a5),a6
  11093.     jsr    _LVORefreshWindowFrame(a6)
  11094. .C    move.l    dosbase(a5),a6
  11095.     moveq    #RETURN_OK,d0
  11096.     rts    
  11097.  
  11098. clkalm    move.l    4.w,a6        ;set alarm-time
  11099.     lea    clktask+1(pc),a1
  11100.     jsr    _LVOFindTask(a6)
  11101.     move.l    dosbase(a5),a6
  11102.     move.l    d0,a4
  11103.     tst.l    d0
  11104.     beq.s    .A
  11105.     tst.l    parm3(a5)
  11106.     bne.s    .B
  11107.     lea    ckalarm(a4),a1
  11108.     bsr    pr_stringlf    show alarm
  11109.     bra.s    .A
  11110. .B    move.l    parm3(a5),a0
  11111.     lea    ckalarm(a4),a1
  11112.     moveq    #7,d0
  11113. .C    move.b    (a0)+,(a1)+    set alarm
  11114.     dbra    d0,.C
  11115. .A    moveq    #RETURN_OK,d0
  11116.     rts    
  11117.  
  11118. clkstart sub.l    a1,a1    ;Here starts the MemClockTaskCode !
  11119.     move.l    4.w,a6
  11120.     jsr    _LVOFindTask(a6)
  11121.     move.l    d0,a5
  11122.     move.l    #$00010100,ckitxt(a5)
  11123. .A    move.l    d5,cknum(a5)    ;teststuff
  11124.     lea    ckdate(a5),a0
  11125.     move.l    a0,d1
  11126.     move.l    ckdos(a5),a6
  11127.     jsr    _LVODateStamp(a6)
  11128.     move.l    ckdate+4(a5),d0        ;mins
  11129.     divu    #60,d0
  11130.     move.w    d0,ckrawdo+8(a5)
  11131.     swap    d0
  11132.     move.w    d0,ckrawdo+10(a5)
  11133.     move.l    ckdate+8(a5),d0        ;secs
  11134.     divu    #50,d0
  11135.     move.w    d0,ckrawdo+12(a5)
  11136.     moveq    #2,d1
  11137.     move.l    4.w,a6
  11138.     jsr    _LVOAvailMem(a6)    ;memory
  11139.     move.l    d0,ckrawdo+4(a5)
  11140.     moveq    #1,d1
  11141.     jsr    _LVOAvailMem(a6)
  11142.     move.l    d0,ckrawdo+0(a5)
  11143.     lea    clkform(pc),a0
  11144.     lea    ckrawdo(a5),a1
  11145.     lea    KPutChar(pc),a2
  11146.     lea    ckcook(a5),a3
  11147.     jsr    _LVORawDoFmt(a6)    ;rawdofmt
  11148.     lea    ckcook+26(a5),a0
  11149.     lea    ckalarm(a5),a1
  11150.     moveq    #7,d0
  11151. .D    move.b    (a0)+,d1
  11152.     cmp.b    (a1)+,d1
  11153.     bne.s    .E
  11154.     dbra    d0,.D
  11155.     move.l    ckint(a5),a6
  11156.     suba.l    a0,a0
  11157.     jsr    _LVODisplayBeep(a6)
  11158. .E    lea    ckcook(a5),a0
  11159.     move.l    a0,ckitxt+12(a5)
  11160.     lea    ckwint(a5),a2
  11161.     moveq    #0,d5
  11162.     moveq    #19,d4
  11163. .B    move.l    (a2)+,a0        ;check all 20 windows
  11164.     move.l    a0,d0
  11165.     beq.s    .C
  11166.     move.l    46(a0),a1    screen
  11167.     move.l    40(a1),d0    font
  11168.     move.l    50(a0),a0    rastport
  11169.     lea    ckitxt(a5),a1
  11170.     move.l    d0,8(a1)
  11171.     addq.l    #1,d5
  11172.     moveq    #0,d0
  11173.     moveq    #1,d1
  11174.     move.l    ckint(a5),a6
  11175.     jsr    _LVOPrintIText(a6)
  11176. .C    dbra    d4,.B
  11177.     moveq    #LF,d1
  11178.     move.l    ckdos(a5),a6
  11179.     jsr    _LVODelay(a6)        ;wait 1/5 sec
  11180.     tst.l    d5
  11181.     bne    .A
  11182.     move.l    4.w,a6
  11183.     rts
  11184.  
  11185.  
  11186. *************************
  11187. *    CONFIG        *    V2.0
  11188. *************************    set or show configuration
  11189. configz    move.l    parm2(a5),d0
  11190.     beq    ctrlerr
  11191.     move.l    d0,a0
  11192.     lea    configuse(pc),a1
  11193. ctrlkey    bsr    CheckOpt    keys pressed with CTRL
  11194.     bne.s    ctrlmor
  11195.     move.l    parm3(a5),d0
  11196.     beq.s    .A
  11197.     move.l    d0,a0
  11198.     lea    ctrl_codes(a5),a1
  11199.     moveq    #ctrl_inite-ctrl_init-2,d1
  11200. .B    move.b    (a0)+,d0
  11201.     beq.s    .D
  11202.     and.b    #$3f,d0        set ctrl codes
  11203.     move.b    d0,(a1)+
  11204.     dbra    d1,.B
  11205.     bra.s    .D
  11206. .A    lea    ctrl_codes(a5),a0    show ctrl codes
  11207.     lea    tempbuf(a5),a1
  11208.     move.l    a1,a2
  11209.     moveq    #ctrl_inite-ctrl_init-2,d1
  11210. .C    move.b    (a0)+,d0
  11211.     add.b    #$40,d0
  11212.     move.b    d0,(a2)+
  11213.     dbra    d1,.C
  11214.     clr.b    (a2)
  11215.     bsr    pr_stringlf
  11216. .D    bra.s    ctrl2
  11217.  
  11218. ctrlmor    bsr    CheckOpt    keys pressed in MORE
  11219.     bne.s    ctrldot
  11220.     move.l    parm3(a5),d0
  11221.     beq.s    .A
  11222.     bsr    parse_echo
  11223.     move.l    parm3(a5),a0
  11224.     lea    morekeys(a5),a1
  11225.     moveq    #more_inite-more_init-1,d1
  11226. .B    move.b    (a0)+,d0
  11227.     beq.s    .D
  11228.     move.b    d0,(a1)+    set MORE keys
  11229.     dbra    d1,.B
  11230.     bra.s    .D
  11231. .A    lea    morekeys(a5),a1    show more keys
  11232.     bsr    pr_stringlf
  11233. .D    bra.s    ctrl2
  11234.  
  11235. ctrldot    bsr    CheckOpt    dot (.) character
  11236.     bne.s    ctrlign
  11237.     move.l    parm3(a5),d0
  11238.     beq    too_less_args
  11239.     move.l    d0,a0
  11240.     move.b    (a0),dotchar(a5)
  11241. ctrl2    bra.s    ctrl3
  11242.  
  11243. ctrlign    bsr    CheckOpt    ignore-string for DIR and FNC
  11244.     bne.s    ctrlcol
  11245.     tst.l    parm3(a5)    set or show exeptions of
  11246.     beq.s    .A        filenamecompletition or dir
  11247.     bsr    FlushFNC
  11248.     move.l    parm3(a5),a0
  11249.     bsr    handle_wild_dirs
  11250.     lea    wild_string(a5),a0
  11251.     lea    FNCignore(a5),a1
  11252.     moveq    #30-2,d0
  11253. .B    move.b    (a0)+,(a1)+
  11254.     beq    .D
  11255.     dbra    d0,.B
  11256.     bra.s    .D
  11257. .A    lea    FNCignore(a5),a1
  11258.     bsr    pr_stringlf
  11259. .D    bra.s    ctrl3
  11260.  
  11261. ctrlcol    bsr    CheckOpt    redefine colors
  11262.     bne.s    ctrlcpy
  11263.     move.l    parm3(a5),d0
  11264.     beq    too_less_args
  11265.     move.l    d0,a3
  11266.     lea    stringstart(pc),a0
  11267.     lea    recol1(pc),a1
  11268.     lea    recol2(pc),a2
  11269.     moveq    #0,d1
  11270.     moveq    #0,d2
  11271.     moveq    #(recol2-recol1)/2-1,d0
  11272. .A    move.w    (a1)+,d1
  11273.     move.b    (a2)+,d2
  11274.     move.b    0(a3,d2.l),d3
  11275.     move.b    d3,0(a0,d1.l)
  11276.     dbra    d0,.A
  11277. ctrl3    bra.s    ctrl4
  11278.  
  11279. ctrlcpy    bsr    CheckOpt    buffer for copy/move/join/split
  11280.     bne.s    ctrlfnc
  11281.     move.l    parm3(a5),d0
  11282.     beq.s    .A
  11283.     move.l    d0,a1
  11284.     bsr    convert_ASCII_to_num
  11285.     beq    bad_number_error
  11286.     move.l    d0,copysize(a5)
  11287.     bra.s    ctrl4
  11288. .A    lea    copysize(a5),a1
  11289. ShowBuffer    ;shows bytesize in (A1)
  11290.     lea    bytes_tx(pc),a0
  11291.     bsr    new_print
  11292.     bra.s    ctrl4
  11293.  
  11294. ctrlfnc    bsr    CheckOpt    buffer for filenamecompletion
  11295.     bne.s    ctrllog
  11296.     tst.l    parm3(a5)
  11297.     bne.s    .A
  11298.     lea    FNCsize(a5),a1
  11299.     bra.s    ShowBuffer
  11300. .A    bsr    FreeFNC
  11301.     move.l    parm3(a5),a1
  11302.     bsr    convert_ASCII_to_num
  11303.     beq    bad_number_error
  11304.     move.l    d0,FNCsize(a5)
  11305. ctrl4    bra.s    ctrlend
  11306.  
  11307. ctrllog    bsr    CheckOpt
  11308.     bne.s    ctrlerr
  11309.     move.l    parm3(a5),d1
  11310.     beq.s    closelog
  11311.     lea    loghandle(pc),a3
  11312.     tst.l    (a3)    logfile already opened ?
  11313.     bne.s    ctrl5
  11314.     bsr    OpenReadWrite    open logfile
  11315.     move.l    d0,(a3)
  11316.     beq    DOSerr
  11317.     move.l    d0,d1
  11318.     moveq    #0,d2    set position
  11319.     moveq    #1,d3    set mode
  11320.     jsr    _LVOSeek(a6)    jump to end of file
  11321.     lea    name_tx(pc),a1
  11322.     bsr    pr_string
  11323.     bsr    rask
  11324.     move.l    a4,a0
  11325.     bsr    write2log
  11326.     lea    lf(pc),a0
  11327.     bsr    write2log
  11328.     bra.s    ctrl5
  11329. closelog lea    loghandle(pc),a2
  11330.     tst.l    (a2)
  11331.     beq.s    ctrl5
  11332.     lea    lf(pc),a0
  11333.     bsr    write2log
  11334.     move.l    (a2),d1
  11335.     jsr    _LVOClose(a6)    close logfile if no filename given
  11336.     clr.l    (a2)
  11337. ctrl5    bra.s    ctrlend
  11338.  
  11339. ctrlerr    lea    configuse(pc),a1
  11340.     bsr    pr_stringlf
  11341. ctrlend    moveq    #RETURN_OK,d0
  11342.     rts
  11343.  
  11344. *************************
  11345. *    Locate        *    V2.0
  11346. ************************* Show the Path and Filename of a Lock-Struct
  11347. locatez            ;or lock object or delete lock
  11348.     bsr    pr_hide_cursor
  11349.     lea    parm2(a5),a3
  11350.     move.l    (a3),d0
  11351.     beq    ShowLocks
  11352.     move.l    d0,a0
  11353.     moveq    #0,d7
  11354.     bsr    return_dash_option
  11355.     cmp.b    #"C",d0
  11356.     bne.s    .F
  11357.     moveq    #-1,d7        delete lock after showing
  11358.     addq.l    #4,a3
  11359.     tst.l    (a3)
  11360.     beq.s    SyntaxError
  11361. .F    move.l    (a3),a1
  11362.     bsr    convert_ASCII_to_num
  11363.     bne.s    ShowLock
  11364.  
  11365.     move.l    4(a3),d0    access mode
  11366.     beq.s    SyntaxError
  11367.     move.l    d0,a0
  11368.     moveq    #ACCESS_READ,d2
  11369.     lea    lockread(pc),a1
  11370.     bsr    CheckOpt
  11371.     beq.s    .E
  11372.     moveq    #ACCESS_WRITE,d2
  11373.     lea    lockwrite(pc),a1
  11374.     bsr    CheckOpt
  11375.     bne.s    SyntaxError
  11376. .E    move.l    (a3),d1        name to lock
  11377.     jsr    _LVOLock(a6)    get new lock
  11378.     tst.l    d0
  11379.     bne.s    ShowLock
  11380. SyntaxError
  11381.     moveq    #-119,d0
  11382.     bra    pr_galactic
  11383.  
  11384. ShowLock
  11385.     lea    -12(sp),sp    write out name of lock
  11386.     move.l    d0,(sp)        d7<>0 : delete lock
  11387.     move.l    d0,d6
  11388.     lsl.l    #2,d0
  11389.     move.l    d0,a0
  11390.     lea    lockwrite(pc),a1
  11391.     moveq    #ACCESS_WRITE,d1
  11392.     cmp.l    fl_Access(a0),d1    what kind of lock
  11393.     beq.s    .C
  11394.     lea    lockread(pc),a1
  11395.     subq.l    #1,d1
  11396.     cmp.l    fl_Access(a0),d1
  11397.     bne.s    .A
  11398. .C    move.l    a1,4(sp)
  11399.     move.l    d6,d1
  11400.     jsr    _LVODupLock(a6)
  11401.     lea    tempbuf(a5),a0
  11402.     move.l    a0,8(sp)
  11403.     bsr    eval_full_path    evaluate the full name
  11404.     jsr    _LVOUnLock(a6)
  11405.     move.l    sp,a1
  11406.     lea    locktext(pc),a0
  11407.     bsr    new_print
  11408. .A    lea    12(sp),sp
  11409.     tst.l    d7
  11410.     beq.s    .G
  11411.     move.l    d6,d1
  11412.     jsr    _LVOUnLock(a6)
  11413.     lea    deleteOK(pc),a1
  11414.     bsr    pr_string
  11415. .G    bra.s    LockOK
  11416.  
  11417. ShowLocks
  11418.     moveq    #0,d3
  11419.     bsr    get_first_devinfo
  11420. .D    moveq    #dlt_device,d1
  11421.     bsr    find_next_assign    walk through dos-list
  11422.     tst.l    d0
  11423.     bne.s    .C
  11424.     move.l    8(a0),packettask(a5)    task
  11425.     beq.s    .D        was non-disk-device
  11426.     bsr    GetDiskInfo
  11427.     beq.s    .D
  11428.     move.l    id_InUse(a5),d0    lock
  11429.     beq.s    .D
  11430. .A    addq.l    #1,d3    count locks
  11431.     movem.l    d0-d3/a0-a2,-(sp)
  11432.     moveq    #0,d7
  11433.     bsr    ShowLock    show lock
  11434.     movem.l    (sp)+,d0-d3/a0-a2
  11435.     lsl.l    #2,d0
  11436.     move.l    d0,a0
  11437.     move.l    (a0),d0
  11438.     bne.s    .A
  11439.     bra.s    .D
  11440. .C    move.l    d3,-(sp)
  11441.     move.l    sp,a1
  11442.     lea    numoflocks(pc),a0
  11443.     bsr    new_print
  11444.     addq.l    #4,sp
  11445. LockOK    moveq    #RETURN_OK,d0
  11446.     rts
  11447.  
  11448. GetDiskInfo    ;device-task must be in packettask(a5), gets info to a5
  11449.     bsr    clearArgs
  11450.     moveq    #ACTION_DISK_INFO,d0
  11451.     move.l    d0,packettype(a5)
  11452.     move.l    a5,d0
  11453.     lsr.l    #2,d0
  11454.     move.l    d0,myArg1(a5)    use FIB as INFO (bptr)
  11455.     bra    sendpacket
  11456.  
  11457. *************************
  11458. *    TaskPri        *    V2.0
  11459. *************************
  11460. taskpriz
  11461.     move.l    parm2(a5),d0
  11462.     beq    too_less_args
  11463.     move.l    d0,a1
  11464.     bsr    convert_ASCII_to_num
  11465.     beq    bad_number_error
  11466.     move.l    d0,d7
  11467.     move.l    parm3(a5),a2
  11468.     bsr    findtsk
  11469.     beq    pr_notfound
  11470.     move.l    d0,a1
  11471.     move.l    d7,d0
  11472.     move.l    4.w,a6
  11473.     jsr    _LVOSetTaskPri(a6)
  11474. tskok    move.l    dosbase(a5),a6
  11475.     moveq    #RETURN_OK,d0
  11476.     rts
  11477.  
  11478. * Find Task given in a2 (ptr,string,cli-number,null)
  11479. * RETURN: d0,a0 address (0 if not found)
  11480. findtsk    moveq    #0,d0
  11481.     move.l    a2,d1
  11482.     beq.s    .E
  11483.     move.l    a2,a1
  11484.     bsr    convert_ASCII_to_num
  11485.     beq.s    .C
  11486. .E    cmp.l    #20,d0
  11487.     bhi.s    .A        is address
  11488.     move.l    d0,a1
  11489.     tst.l    d0        0 means own task
  11490.     beq.s    .D
  11491.     lsl.l    #2,d0        is a cli-number
  11492.     move.l    dl_Root(a6),a0
  11493.     move.l    (a0),a0
  11494.     add.l    a0,a0
  11495.     add.l    a0,a0
  11496.     add.l    d0,a0
  11497.     move.l    (a0),d0
  11498.     beq.s    .B
  11499.     sub.l    #pr_MsgPort,d0
  11500.     bra.s    .A
  11501. .C    move.l    a2,a1
  11502. .D    move.l    4.w,a6
  11503.     jsr    _LVOFindTask(a6)    search name
  11504.     move.l    dosbase(a5),a6
  11505. .A    tst.l    d0
  11506.     beq.s    .B
  11507.     move.l    d0,a0
  11508.     cmp.b    #01,LN_TYPE(a0)    is it a TASK-struct ?
  11509.     beq.s    .B
  11510.     cmp.b    #13,LN_TYPE(a0)    is it a PROCESS-struct ?
  11511.     beq.s    .B
  11512.     moveq    #0,d0
  11513. .B    tst.l    d0
  11514.     rts
  11515.  
  11516. *************************
  11517. *    Break        *    V2.0
  11518. *************************
  11519. breakz    move.l    parm2(a5),d0
  11520.     beq    too_less_args
  11521.     move.l    d0,a2
  11522.     bsr    findtsk
  11523.     beq    pr_notfound
  11524.     move.l    d0,a2
  11525.     move.l    tc_SigWait(a2),d0
  11526.     move.l    parm3(a5),d1
  11527.     beq.s    .C
  11528.     move.l    d1,a1
  11529.     move.b    (a1),d2
  11530.     bsr    convert_ASCII_to_num
  11531.     bne.s    .C
  11532.     moveq    #RETURN_ERROR,d0
  11533.     bclr    #5,d2
  11534.     cmp.b    #"C",d2
  11535.     blo.s    .A
  11536.     cmp.b    #"F",d2
  11537.     bhi.s    .A
  11538.     sub.b    #55,d2
  11539.     moveq    #0,d0
  11540.     bset    d2,d0
  11541. .C    move.l    a2,a1
  11542.     move.l    4.w,a6
  11543.     jsr    _LVOSignal(a6)    set signals given in mask
  11544.     move.l    dosbase(a5),a6
  11545.     moveq    #RETURN_OK,d0
  11546. .A    rts
  11547.  
  11548. *************************
  11549. *    PutMsg        *    V2.0
  11550. *************************
  11551. putmsgz    move.l    parm2(a5),d7
  11552.     beq    printa5
  11553.     move.l    d7,a1
  11554.     bsr    convert_ASCII_to_num
  11555.     bne.s    .D
  11556.     move.l    d7,a1
  11557.     move.l    4.w,a6
  11558.     jsr    _LVOFindPort(a6)    search name
  11559.     move.l    dosbase(a5),a6
  11560.     tst.l    d0
  11561.     beq.s    .B
  11562.     move.l    d0,a0
  11563.     bra.s    .E
  11564. .D    move.l    d0,a0
  11565.     cmp.l    #20,d0
  11566.     bls.s    .B
  11567.     cmp.b    #04,LN_TYPE(a0)    is it a MSGPORT-struct ?
  11568.     beq.s    .E
  11569. .B    move.l    d7,a2
  11570.     bsr    findtsk        search task
  11571.     bne.s    .C
  11572. .A    bra    pr_notfound
  11573. .C    cmp.b    #13,LN_TYPE(a0)    is it a PROCESS-struct ?
  11574.     bne.s    .A
  11575.     lea    pr_MsgPort(a0),a0
  11576. .E    bsr    clearArgs
  11577.     move.l    thistask(a5),a2
  11578.     lea    pr_MsgPort(a2),a2
  11579.     move.l    a2,sp_reply(a5)
  11580.     move.b    #5,LN_TYPE+sp_node(a5)
  11581.     lea    parm3(a5),a2
  11582.     lea    sp_link(a5),a3
  11583.     moveq    #mn_Size,d2
  11584. .G    move.l    (a2)+,d3
  11585.     beq.s    .F
  11586.     move.l    d3,a1
  11587.     bsr    convert_ASCII_to_num
  11588.     bne.s    .H
  11589.     move.l    d3,d0
  11590. .H    move.l    d0,(a3)+
  11591.     addq.w    #4,d2
  11592.     bra.s    .G
  11593. .F    move.w    d2,sp_length(a5)
  11594.     move.l    sp_link(a5),a1
  11595.     move.b    (a1),d0
  11596.     cmp.b    dotchar(a5),d0
  11597.     bne.s    .I
  11598.     lea    sp_link(a5),a1        for DOSpackets
  11599.     move.l    a1,LN_NAME+sp_node(a5)
  11600.     lea    sp_node(a5),a1
  11601.     move.l    a1,sp_link(a5)
  11602.     move.l    sp_reply(a5),sp_port(a5)
  11603. .I    lea    msendtx(pc),a1
  11604.     bsr    pr_stringlf
  11605.     lea    sp_node(a5),a1        message
  11606.     move.l    4.w,a6
  11607.     jsr    _LVOPutMsg(a6)
  11608.     move.l    dosbase(a5),a6
  11609.     clr.l    parm2(a5)
  11610.     bra.s    getmsg1
  11611.  
  11612. *************************
  11613. *    GetMsg        *    V2.0
  11614. *************************
  11615. getmsgz    moveq    #0,d7
  11616.     moveq    #0,d6
  11617.     move.l    parm2(a5),d2
  11618.     beq.s    getmsg1
  11619.     move.l    d2,a1
  11620.     move.l    4.w,a6
  11621.     jsr    _LVOFindPort(a6)    does it already exist ?
  11622.     tst.l    d0
  11623.     bne.s    getmsg1
  11624.     move.l    thistask(a5),a1
  11625.     lea    pr_MsgPort(a1),a1
  11626.     move.l    d2,LN_NAME(a1)
  11627.     jsr    _LVOAddPort(a6)
  11628.     moveq    #1,d6
  11629. getmsg1    move.l    thistask(a5),a2
  11630.     lea    pr_MsgPort(a2),a2
  11631.     move.l    4.w,a6
  11632.     move.l    a2,a0
  11633.     jsr    _LVOGetMsg(a6)
  11634.     tst.l    d0
  11635.     bne.s    .A
  11636.     moveq    #0,d2
  11637.     move.b    MP_SIGBIT(a2),d1
  11638.     bset    d1,d2
  11639.     bset    #SIGBREAKB_CTRL_C,d2
  11640.     move.l    d2,d1
  11641. ;    moveq    #0,d0
  11642.     jsr    _LVOSetSignal(a6)    clear signals
  11643.     move.l    d2,d0
  11644.     jsr    _LVOWait(a6)    wait for msgport or ctrl-c
  11645.     move.l    a2,a0
  11646.     jsr    _LVOGetMsg(a6)
  11647. .A    move.l    dosbase(a5),a6
  11648.     tst.l    d0
  11649.     beq    msgfail
  11650.     move.l    d0,a2
  11651.     move.w    mn_Length(a2),d2
  11652.     move.w    d2,-(sp)
  11653.     move.l    a2,-(sp)
  11654.     lea    msgtx(pc),a0
  11655.     move.l    sp,a1
  11656.     bsr    new_print
  11657.     addq.l    #6,sp
  11658.     sub.w    #mn_Size,d2
  11659.     lsr.w    #2,d2
  11660.     lea    mn_Size(a2),a3
  11661.     bra.s    .D
  11662. .C    move.l    (a3)+,d0
  11663.     cmp.l    #$dfe000,d0
  11664.     bhs.s    .E
  11665.     cmp.l    #$a00000,d0
  11666.     blo.s    .F
  11667.     cmp.l    #$c00000,d0
  11668.     blo.s    .E
  11669. .F    move.l    d0,a0
  11670.     moveq    #79,d1
  11671. .H    move.b    (a0)+,d3
  11672.     beq.s    .G
  11673.     cmp.b    #" ",d3
  11674.     blo.s    .E
  11675.     cmp.b    #"~",d3
  11676.     bhi.s    .E
  11677.     dbra    d1,.H
  11678.     bra.s    .E
  11679. .G    cmp.w    #76,d1
  11680.     bhs.s    .E
  11681.     bsr    printADR
  11682.     bsr    pr_space
  11683.     move.l    d0,a1
  11684.     bsr    pr_stringlf
  11685.     bra.s    .D
  11686. .E    bsr    printADR
  11687.     bsr    pr_lf
  11688. .D    dbra    d2,.C
  11689.     tst.l    d7
  11690.     bne.s    .B
  11691.     tst.l    d6
  11692.     beq.s    .I
  11693.     move.l    thistask(a5),a1
  11694.     lea    pr_MsgPort(a1),a1
  11695.     move.l    4.w,a6
  11696.     jsr    _LVORemPort(a6)
  11697.     move.l    dosbase(a5),a6
  11698. .I    lea    replytx(pc),a1
  11699.     bsr    pr_string
  11700.     bsr    rask
  11701.     move.l    d0,d2
  11702.     beq.s    .B
  11703.     move.l    4.w,a6
  11704.     move.l    a2,a1
  11705.     jsr    _LVOReplyMsg(a6)
  11706.     move.l    dosbase(a5),a6
  11707.     cmp.b    #RETURN_ERROR,d2
  11708.     beq    getmsg1
  11709. .B    moveq    #RETURN_OK,d0
  11710.     rts
  11711. printa5    move.l    a5,-(sp)
  11712.     move.l    sp,a1
  11713.     lea    pra5tx(pc),a0
  11714.     bsr    new_print
  11715.     addq.l    #4,sp
  11716.     bsr    DisplayBeep
  11717. msgfail    moveq    #RETURN_ERROR,d0
  11718.     rts
  11719.  
  11720. *************************
  11721. *    Border        *    V2.0
  11722. *************************
  11723. borderz    move.l    parm2(a5),a0
  11724.     bsr    CheckOnOff
  11725.     move.l    d0,-(sp)
  11726.     move.l    windowptr(a5),d0
  11727.     beq    nosiz
  11728.     move.l    d0,a0
  11729.     move.l    a0,a4        this window
  11730.     move.l    intuibase(a5),a6
  11731.     moveq    #0,d0
  11732.     jsr    _LVOLockIBase(a6)
  11733.     move.l    d0,d7
  11734.     move.l    (sp)+,d0
  11735.     beq    bordoff
  11736.  
  11737. bordon    tst.l    bordersize(a5)
  11738.     beq.s    borne
  11739.     bclr    #3,wd_Flags+2(a4)    unset noborder (bit 11)
  11740.     move.l    bordersize(a5),wd_BorderLeft(a4)
  11741.     bra.s    borjo
  11742.  
  11743. bordoff    tst.l    wd_BorderLeft(a4)
  11744.     beq.s    borjo
  11745.     bset    #3,wd_Flags+2(a4)    set noborder-window (bit 11)
  11746.     move.l    wd_BorderLeft(a4),bordersize(a5)
  11747.     clr.l    wd_BorderLeft(a4)
  11748. borjo    moveq    #$00,d0        null resize
  11749.     moveq    #$00,d1
  11750.     move.l    a4,a0
  11751.     jsr    _LVOSizeWindow(a6)
  11752.     move.l    a4,a0
  11753.     jsr    _LVORefreshWindowFrame(a6)    redraw
  11754. borne    move.l    d7,a0
  11755.     jsr    _LVOUnlockIBase(a6)
  11756.     move.l    parm3(a5),d0
  11757.     beq.s    nosiz
  11758.     move.l    d0,a1
  11759.     bsr    convert_ASCII_to_num
  11760.     tst.l    d1
  11761.     beq.s    nosiz
  11762.                 ;resize window to fill screen
  11763.     move.l    $2e(a4),a1    points to screen
  11764.     move.l    d0,d4    width of menubar
  11765.     bpl.s    .A
  11766.     moveq    #0,d4
  11767.     move.b    30(a1),d4
  11768.     add.b    31(a1),d4
  11769. .A    moveq    #-1,d2
  11770.     move.l    12(a1),d3
  11771.     sub.w    10(a4),d3
  11772.     sub.w    d4,d3
  11773.     move.w    d3,d1
  11774.     bpl.s    bklein
  11775.     moveq    #0,d2
  11776.     moveq    #0,d0
  11777.     move.l    a4,a0
  11778.     jsr    _LVOSizeWindow(a6)
  11779. bklein    moveq    #0,d0
  11780.     sub.w    4(a4),d0
  11781.     move.l    d4,d1
  11782.     sub.w    6(a4),d1
  11783.     move.l    a4,a0
  11784.     jsr    _LVOMoveWindow(a6)
  11785.     moveq    #0,d1
  11786.     tst.b    d2
  11787.     beq.s    bgross
  11788.     move.w    d3,d1
  11789. bgross    swap    d3
  11790.     sub.w    8(a4),d3
  11791.     move.w    d3,d0
  11792.     move.l    a4,a0
  11793.     jsr    _LVOSizeWindow(a6)
  11794.     jsr    _LVORethinkDisplay(a6)
  11795.     
  11796. nosiz    move.l    dosbase(a5),a6
  11797.     moveq    #10,d1        wait more than 1/10 sec
  11798.     jsr    _LVODelay(a6)
  11799.     moveq    #RETURN_OK,d0
  11800.     rts
  11801.  
  11802. *************************
  11803. *    Review        *    V2.1
  11804. *************************
  11805. reviewz    move.l    parm2(a5),d0
  11806.     beq.s    ShowReview
  11807.     move.l    d0,a1
  11808.     move.l    d0,a2
  11809.     bsr    convert_ASCII_to_num
  11810.     bne.s    MakeReview
  11811.     addq.l    #1,a2
  11812.     or.b    #$20,(a2)
  11813.     cmp.b    #"c",(a2)
  11814.     beq.s    ClearReview
  11815.     cmp.b    #"s",(a2)
  11816.     bne.s    ShowReview
  11817.     move.l    parm3(a5),d0        Save review-buffer
  11818.     beq    too_less_args
  11819.     tst.l    ReviewSize(a5)
  11820.     beq.s    ShowReview
  11821.     move.l    d0,a3
  11822.     bra    viewbuffer
  11823.  
  11824. ShowReview
  11825.     lea    ReviewSize(a5),a1    Show review-info
  11826.     bra    ShowBuffer
  11827.  
  11828. ClearReview
  11829.     move.l    ReviewMem(a5),a0
  11830.     move.l    ReviewSize(a5),d0
  11831.     move.l    d0,d1
  11832.     swap    d1
  11833.     bra.s    .D
  11834. .E    move.b    #" ",(a0)+    Fill with spaces
  11835. .D    dbra    d0,.E
  11836.     dbra    d1,.E
  11837.     move.b    #LF,-1(a0)    Last char is LF
  11838.     clr.l    ReviewPtr(a5)
  11839.     moveq    #RETURN_OK,d0
  11840.     rts
  11841.  
  11842. MakeReview
  11843.     btst    #FLraw,Flags+2(a5)    only in raw mode
  11844.     beq.s    .A
  11845.     tst.l    d0            Add review-buffer
  11846.     beq.s    .A
  11847.     tst.l    ReviewSize(a5)
  11848.     beq.s    .F
  11849.     move.l    d0,-(sp)
  11850.     bsr    reviewend
  11851.     move.l    (sp)+,d0
  11852. .F    move.l    d0,d2
  11853.     bsr    iwantmem
  11854.     beq    ShowReview
  11855.     move.l    d0,ReviewMem(a5)
  11856.     move.l    d2,ReviewSize(a5)
  11857.     bsr    ClearReview
  11858.     clr.l    ReviewPtr(a5)
  11859.     lea    RHa3(pc),a3        Look for a5-Table
  11860.     tst.l    (a3)
  11861.     bne.s    entryA5
  11862.     moveq    #80,d0
  11863.     bsr    iwantcleanmem
  11864. .A    beq    reviewend
  11865.     move.l    d0,(a3)
  11866. APatch    moveq    #_LVOWrite,d2        Add review-patch to DOS Write
  11867.     move.w    #$4ef9,d3
  11868.     move.l    a6,a2
  11869.     add.l    d2,a2
  11870.     moveq    #0,d1
  11871.     cmp.w    (a2),d3
  11872.     bne.s    .B
  11873.     move.l    2(a2),a0
  11874.     lea    RCode(pc),a1
  11875.     cmp.l    a1,a0
  11876.     beq.s    entryA5
  11877.     moveq    #-1,d1
  11878.     bra.s    .C
  11879. .B    cmp.w    #$6000,2(a2)
  11880.     bne.s    reviewend
  11881. .C    movem.l    d0-d1/a0-a1,-(sp)
  11882.     bsr    do_forbid
  11883.     movem.l    (sp)+,d0-d1/a0-a1
  11884.     lea    RHa1(pc),a1
  11885.     move.w    (a2),(a1)
  11886.     move.l    2(a2),2(a1)
  11887.     tst.w    d1
  11888.     bne.s    .D
  11889.     lea    4(a2),a0
  11890.     move.w    (a0),d0
  11891.     ext.l    d0
  11892.     add.l    d0,a0
  11893.     move.l    a0,4(a1)
  11894.     move.w    d3,2(a1)
  11895. .D    lea    RCode(pc),a0
  11896.     move.w    d3,(a2)
  11897.     move.l    a0,2(a2)
  11898.     bsr    do_permit
  11899. entryA5    move.l    (a3),a3            Add a5-table entry
  11900.     moveq    #20-1,d0
  11901. .F    tst.l    (a3)+
  11902.     beq.s    .G
  11903.     dbra    d0,.F
  11904.     bra    reviewend
  11905. .G    move.l    a5,-4(a3)
  11906.     bra    reviewOK
  11907.  
  11908. reviewend        ;Remove review-buffer
  11909.     move.l    RHa3(pc),d0        Remove a5-table entry
  11910.     beq.s    remmem2
  11911.     move.l    d0,a0
  11912.     move.l    a0,a1
  11913.     move.l    a0,a2
  11914.     moveq    #20-1,d0
  11915. .A    cmp.l    (a0)+,a5
  11916.     beq.s    .B
  11917.     dbra    d0,.A
  11918.     bra.s    .D
  11919. .B    clr.l    -4(a0)
  11920. .D    moveq    #20-1,d0    look for other entries
  11921. .C    tst.l    (a2)+
  11922.     bne.s    remmem2
  11923.     dbra    d0,.C
  11924.     bsr    do_forbid
  11925.     lea    RHa3(pc),a0
  11926.     clr.l    (a0)
  11927.     moveq    #80,d0        last entry
  11928.     bsr    givemem
  11929.     moveq    #_LVOWrite,d0        Remove DOS Write Patch
  11930.     move.l    a6,a3
  11931.     add.l    d0,a3
  11932.     move.l    2(a3),a0
  11933.     lea    RCode(pc),a1
  11934.     cmp.l    a0,a1
  11935.     bne.s    remmem
  11936.     lea    RHa1(pc),a1
  11937.     move.w    (a1),(a3)
  11938.     move.l    2(a1),2(a3)
  11939.     cmp.w    #$4ef9,(a1)
  11940.     beq.s    remmem
  11941.     move.w    #$6000,2(a3)
  11942.     lea    4(a3),a2
  11943.     move.l    4(a1),d0
  11944.     sub.l    a2,d0
  11945.     move.w    d0,(a2)
  11946. remmem    bsr    do_permit
  11947. remmem2    move.l    ReviewSize(a5),d0    Remove buffer-memory
  11948.     beq.s    reviewOK
  11949.     move.l    ReviewMem(a5),a1
  11950.     bsr    givemem
  11951.     clr.l    ReviewSize(a5)
  11952. reviewOK
  11953.     moveq    #RETURN_OK,d0
  11954.     rts
  11955.  
  11956. viewbuffer        ;Show the review-buffer using more
  11957.     move.l    ReviewMem(a5),a2
  11958.     move.l    ReviewPtr(a5),d3
  11959.     move.l    ReviewSize(a5),d2
  11960.     bne.s    viewhist
  11961.     rts
  11962. viewhist    ;Show a circular buffer using more
  11963.     move.l    d2,d4
  11964.     move.l    MPipePtr(a5),d1
  11965.     beq.s    .A
  11966.     move.l    d3,d0    for redirecting to more
  11967.     move.l    d1,d3
  11968.     sub.l    d0,d1
  11969.     bpl.s    .C
  11970.     add.l    d2,d1
  11971.     bra.s    .C
  11972. .A
  11973. .I    move.b    0(a2,d3.l),d0
  11974.     addq.l    #1,d3
  11975.     cmp.l    d3,d2
  11976.     bhi.s    .B
  11977.     clr.l    d3
  11978. .B    addq.l    #1,d1
  11979.     cmp.b    #LF,d0
  11980.     beq.s    .C
  11981.     cmp.b    #12,d0
  11982.     bne.s    .I
  11983. .C    sub.l    d1,d2
  11984.     move.l    d2,d0
  11985.     beq.s    reviewOK
  11986.     bsr    iwantmem
  11987.     beq.s    reviewOK
  11988.     move.l    d0,a0
  11989.     move.l    a0,a1
  11990.     move.l    d4,d1
  11991.     move.l    d2,d4
  11992.     move.l    d2,d5
  11993.     swap    d5
  11994.     bra.s    .E
  11995. .D    move.b    0(a2,d3.l),d0
  11996.     cmp.b    #12,d0
  11997.     bne.s    .G
  11998.     move.b    #LF,d0
  11999. .G    cmp.b    #"c",d0
  12000.     bne.s    .H
  12001.     cmp.b    #27,-1(a0)
  12002.     bne.s    .H
  12003.     move.b    #LF,-1(a0)
  12004.     move.b    #LF,d0
  12005. .H    move.b    d0,(a0)+
  12006.     addq.l    #1,d3
  12007.     cmp.l    d3,d1
  12008.     bhi.s    .E
  12009.     clr.l    d3
  12010. .E    dbra    d2,.D
  12011.     dbra    d5,.D
  12012.     move.l    a3,d0
  12013.     bne.s    viewwrite
  12014.     move.l    a1,d0
  12015.     move.l    d4,d1
  12016.     moveq    #-1,d2
  12017.     tst.l    MPipePtr(a5)
  12018.     beq.s    .F
  12019.     moveq    #0,d2
  12020. .F    moveq    #0,d4
  12021.     bra    ViewMore
  12022. viewwrite        ;write buffer to file
  12023.     move.l    a1,a2
  12024.     move.l    a3,d1
  12025.     bsr    OpenNewfile
  12026.     tst.l    d0
  12027.     beq.s    .A
  12028.     move.l    d0,a3
  12029.     move.l    a3,d1
  12030.     move.l    a2,d2
  12031.     move.l    d4,d3
  12032.     move.l    d3,-(sp)
  12033.     jsr    _LVOWrite(a6)
  12034.     move.l    (sp)+,d3
  12035.     sub.l    d0,d3
  12036.     move.l    a3,d1
  12037.     jsr    _LVOClose(a6)
  12038.     moveq    #1,d0
  12039.     tst.l    d3
  12040.     beq.s    .A
  12041.     moveq    #0,d0
  12042. .A    move.l    d0,d2
  12043.     move.l    d4,d0
  12044.     move.l    a2,a1
  12045.     bsr    givemem
  12046.     tst.l    d2
  12047.     beq    DOSerr
  12048.     bra    reviewOK
  12049.  
  12050.     
  12051.  
  12052. *****    ReviewHandler    ********
  12053. RHa1    dc.w    $4ef9    JMP
  12054. RHa2    dcb.w    3,0    Return-Code
  12055. RHa3    dcb.l    1,0    Memory-Base-Table
  12056.  
  12057. RCode    movem.l    d0-d3/a5-a6,-(sp)    ;Is called by the DOS Write fkt.
  12058.     move.l    RHa3(pc),d0
  12059.     beq.s    .C
  12060.     move.l    d0,a0
  12061.     moveq    #20-1,d0
  12062. .B    move.l    (a0)+,a5
  12063.     cmp.l    outhandle(a5),d1    same outhandle ?
  12064.     bne.s    .D
  12065.     tst.b    redirect_out(a5)    not output-redirected ?
  12066.     beq.s    .A
  12067.     tst.l    MPipePtr(a5)        or review to MORE ?
  12068.     bne.s    .A
  12069. .D    dbra    d0,.B
  12070.     bra.s    .C
  12071. .A    tst.b    noreview_flag(a5)
  12072.     bne.s    .C
  12073.     bsr    toreview
  12074. .C    movem.l    (sp)+,d0-d3/a5-a6
  12075.     bra.s    RHa1
  12076.  
  12077. toreview    ;Writes data to review-buffer,Entry: d2=Adress, d3=Length
  12078.     move.l    d2,a0
  12079.     move.l    ReviewMem(a5),a1
  12080.     move.l    ReviewPtr(a5),d1
  12081.     move.l    ReviewSize(a5),d2
  12082.     beq.s    .C
  12083.     move.l    d3,d0
  12084.     swap    d0
  12085.     bra.s    .B
  12086. .A    move.b    (a0)+,0(a1,d1.l)
  12087.     addq.l    #1,d1
  12088.     cmp.l    d1,d2
  12089.     bhi.s    .B
  12090.     clr.l    d1
  12091. .B    dbra    d3,.A
  12092.     dbra    d0,.A
  12093.     move.l    d1,ReviewPtr(a5)
  12094. .C    rts
  12095.  
  12096.  
  12097. **********************************************************************
  12098. ; check if string in a0 is same as in a1 (limited by null,comma,space)
  12099. ; return: d0=0 for match, 1 otherwise
  12100. CheckOpt    
  12101.     move.l    a0,-(sp)
  12102.     cmp.b    #$22,-1(a0)    options are not enclosed in quotes
  12103.     beq.s    .H
  12104.     move.b    dotchar(a5),d0
  12105.     bsr    CheckOneChar    single dotchar is not an option
  12106.     beq.s    .H
  12107. .A    move.b    (a1)+,d1    compare things
  12108.     beq.s    .B
  12109.     cmp.b    #" ",d1
  12110.     beq.s    .B
  12111.     cmp.b    #",",d1
  12112.     beq.s    .B
  12113.     move.b    (a0)+,d0
  12114.     beq.s    .H
  12115.     cmp.b    dotchar(a5),d0    check for .
  12116.     bne.s    .F
  12117.     tst.b    (a0)
  12118.     beq.s    .G
  12119. .F    bsr    compD1D0nocase
  12120.     beq.s    .A
  12121. .H    moveq    #1,d0        failed (not matched)
  12122.     bra.s    .E
  12123. .G    moveq    #0,d0        success    (abbreviated)
  12124. .E    move.b    (a1)+,d1    search for end
  12125.     beq.s    .D
  12126.     cmp.b    #" ",d1
  12127.     beq.s    .D
  12128.     cmp.b    #",",d1
  12129.     bne.s    .E
  12130.     bra.s    .D
  12131. .B    moveq    #1,d0        success or a0 is too long ?
  12132.     tst.b    (a0)
  12133.     bne.s    .D
  12134.     moveq    #0,d0        length is same -> success
  12135. .D    move.l    (sp)+,a0
  12136.     tst.l    d0
  12137.     rts
  12138.  
  12139. *************************
  12140. ; check a0 for ON (d0=1) or OFF (d0=0) option, otherwise error-exit
  12141. CheckOnOff
  12142.     move.l    a2,-(sp)
  12143.     lea    onoffuse(pc),a2
  12144.     move.l    a0,d0
  12145.     beq.s    .B
  12146.     lea    6(a2),a1
  12147.     bsr    CheckOpt
  12148.     beq.s    .A
  12149.     move.l    a2,a1
  12150.     bsr    CheckOpt
  12151.     bne.s    .B
  12152.     moveq    #1,d0
  12153. .A    move.l    (sp)+,a2
  12154.     rts
  12155. .B    move.l    a2,a0
  12156. *************************
  12157. ; print error in a0 and exit
  12158. ErrorExit
  12159.     bsr    PrintError
  12160.     bra    galactic
  12161.  
  12162. *************************
  12163. ; check for Kickstart 2.0 or better, exit on error
  12164. CheckKS    lea    oldkick_tx(pc),a0
  12165.     cmp.w    #36,kickver(a5)
  12166.     blo.s    ErrorExit
  12167.     rts
  12168.  
  12169. **********************************************************************
  12170. ; check if option in a0 is in parm-list and deletes it from parm-list
  12171. ; return: d0=0 for match, 1 otherwise
  12172. LookForOpt
  12173.     movem.l    a2-a3,-(sp)
  12174.     move.l    a0,a2
  12175.     lea    parm2(a5),a3
  12176. .A    move.l    (a3)+,d0    search all parms
  12177.     beq.s    .B
  12178.     move.l    a2,a1
  12179.     move.l    d0,a0
  12180.     bsr    CheckOpt    look for option
  12181.     bne.s    .A
  12182.     lea    -4(a3),a2    found it !
  12183. .D    move.l    (a3)+,(a2)+    delete found parm
  12184.     bne.s    .D
  12185.     moveq    #0,d0
  12186.     bra.s    .C
  12187. .B    moveq    #1,d0        not found !
  12188. .C    movem.l    (sp)+,a2-a3
  12189.     rts
  12190.  
  12191. *************************
  12192. *    MakeLink    *    V2.3
  12193. *************************
  12194. makelinkz
  12195.     bsr    CheckKS
  12196.     moveq    #0,d7
  12197.     moveq    #0,d3
  12198.     move.l    parm4(a5),d0
  12199.     beq.s    .B
  12200.     move.l    d0,a0
  12201.     lea    softtx(pc),a1
  12202.     bsr    CheckOpt
  12203.     bne    SyntaxError
  12204.     moveq    #-1,d3
  12205. .B    move.l    parm3(a5),d1
  12206.     beq    too_less_args
  12207.     move.l    d1,d2
  12208.     tst.l    d3
  12209.     bne.s    .D
  12210.     moveq    #-2,d2
  12211.     jsr    _LVOLock(a6)
  12212.     move.l    d0,d7
  12213.     beq    DOSerr
  12214.     move.l    d0,d2
  12215. .D    move.l    parm2(a5),d1
  12216.     jsr    _LVOMakeLink(a6)
  12217.     tst.l    d0
  12218.     beq    DOSerrUL
  12219.     move.l    d7,d1
  12220.     beq.s    .A
  12221.     jsr    _LVOUnLock(a6)
  12222. .A    moveq    #RETURN_OK,d0
  12223.     rts
  12224.  
  12225. *************************
  12226. *    Flags        *    V2.3
  12227. *************************
  12228. flagsz    bsr    pr_hide_cursor
  12229.     lea    parm2(a5),a3
  12230.     move.l    Flags(a5),d3
  12231.     tst.l    (a3)
  12232.     beq.s    .F
  12233. .A    move.l    d3,d0
  12234.     bsr    SetFlags
  12235.     move.l    (a3)+,d0
  12236.     beq.s    .C
  12237.     move.l    d0,a0
  12238.     lea    flagsuse(pc),a1
  12239.     moveq    #0,d2
  12240. .B    bsr    CheckOpt    look for flag
  12241.     beq.s    .D
  12242.     addq.w    #1,d2
  12243.     cmp.w    #MaxFlags,d2
  12244.     bne.s    .B
  12245.     lea    flagsuse(pc),a1
  12246.     bsr    pr_stringlf
  12247.     bra.s    .C
  12248. .D    move.l    (a3)+,a0    change flag
  12249.     bclr    d2,d3
  12250.     bsr    CheckOnOff
  12251.     beq.s    .A
  12252.     bset    d2,d3
  12253.     bra.s    .A
  12254.  
  12255. .F    moveq    #0,d2        print all flags
  12256.     lea    flagsuse(pc),a3
  12257. .E    lea    temp2buf(a5),a2
  12258. .G    move.b    (a3)+,d0
  12259.     move.b    d0,(a2)+
  12260.     cmp.b    #" ",d0
  12261.     beq.s    .H
  12262.     cmp.b    #",",d0
  12263.     bne.s    .G
  12264. .H    subq.l    #1,a2
  12265.     lea    flagsoff(pc),a1
  12266.     btst    d2,d3
  12267.     beq.s    .I
  12268.     lea    flagson(pc),a1
  12269. .I    bsr    addstring
  12270.     lea    temp2buf(a5),a1
  12271.     bsr    pr_string
  12272.     addq.w    #1,d2
  12273.     cmp.w    #MaxFlags,d2
  12274.     bne.s    .E
  12275. .C    moveq    #RETURN_OK,d0
  12276.     rts
  12277.  
  12278. SetFlags
  12279.     cmp.w    #36,kickver(a5)
  12280.     bhs.s    .A
  12281.     and.l    #-1-%1100,d0    ICON and WILD not possible with OS1.3
  12282. .A    move.l    d0,Flags(a5)    set Flags
  12283.     rts
  12284.  
  12285. *************************
  12286. *    MakeIcon    *    V2.3
  12287. *************************
  12288. makeiconz
  12289.     bsr    CheckKS
  12290.     move.l    parm2(a5),d3
  12291.     beq    too_less_args
  12292.     move.l    parm3(a5),d0
  12293.     beq.s    .E
  12294.     move.l    d0,a0
  12295.     moveq    #1,d2
  12296.     lea    iconuse(pc),a1
  12297. .D    bsr    CheckOpt
  12298.     beq.s    .C
  12299.     addq.l    #1,d2
  12300.     cmp.b    #9,d2
  12301.     bne.s    .D
  12302. .B    move.l    dosbase(a5),a6
  12303.     lea    iconuse(pc),a1
  12304.     bsr    pr_stringlf
  12305.     bra.s    .A
  12306. .C    bsr    OpenIconLib
  12307.     beq.s    .B
  12308.     move.l    d2,d0
  12309.     jsr    _LVOGetDefDiskObject(a6)
  12310.     move.l    d0,d2
  12311.     beq    resi_not_found
  12312.     move.l    d0,a1
  12313.     move.l    d3,a0
  12314.     jsr    _LVOPutDiskObject(a6)
  12315.     move.l    d0,d3
  12316.     move.l    d2,a0
  12317.     jsr    _LVOFreeDiskObject(a6)
  12318.     tst.l    d3
  12319.     beq    resi_not_found
  12320. .A    move.l    dosbase(a5),a6
  12321.     moveq    #RETURN_OK,d0
  12322.     rts
  12323.  
  12324. .E    ;shows icon using wb.lib's wbinfo
  12325.     cmp.w    #39,kickver(a5)        needs OS3.0+
  12326.     blo.s    .B
  12327.     bsr    OpenWBLib
  12328.     beq.s    .B
  12329.     move.l    thistask(a5),a0
  12330.     move.l    pr_CurrentDir(a0),a0
  12331.     move.l    parm2(a5),a1
  12332.     move.l    iconbase(a5),a2
  12333.     move.l    $38(a2),a2
  12334.     jsr    _LVOWBInfo(a6)
  12335.     bra.s    .A
  12336.  
  12337. *************************
  12338. *    Split        *    V2.6
  12339. *************************
  12340. splitz    tst.l    parm4(a5)
  12341.     beq    too_less_args
  12342.     moveq    #0,d5
  12343.     moveq    #0,d7        d7=current number
  12344.     clr.l    devproc(a5)
  12345.     clr.l    temp2(a5)
  12346.     bset    #DLsplit,temp2+1(a5)    split flag
  12347.     bsr    check_q_r
  12348.     move.l    parm4(a5),a1    get length
  12349.     bsr    convert_ASCII_to_num
  12350.     beq    bad_number_error
  12351.     move.l    d0,a3
  12352.     move.l    parm2(a5),d1
  12353.     bsr    OpenOldfile    open input file
  12354.     move.l    d0,d4        d4=input file handle
  12355.     beq    perr3
  12356.     move.l    parm5(a5),d0    may get offset
  12357.     beq.s    .A
  12358.     move.l    d0,a1
  12359.     bsr    convert_ASCII_to_num
  12360.     beq.s    .A
  12361.     move.l    d4,d1
  12362.     move.l    d0,d2
  12363.     moveq    #-1,d3
  12364.     jsr    _LVOSeek(a6)    skip offset
  12365. .A    bsr    GetCopyBlock
  12366.     beq.s    splend
  12367.  
  12368. sploop    move.l    parm3(a5),a0
  12369.     lea    tempbuf(a5),a1
  12370.     move.l    a1,d1
  12371. .A    move.b    (a0)+,(a1)+    copy output name
  12372.     bne.s    .A
  12373.     subq.l    #1,a1
  12374.     addq.l    #1,d7
  12375.     move.l    d7,d0
  12376.     bsr    qpr10        append number to name
  12377.     clr.b    (a1)
  12378.     move.l    d1,a1
  12379.     bsr    pr_string
  12380.     bsr    pr_space
  12381.     bsr    AskYesNo    ask
  12382.     beq.s    .B
  12383.     bsr    check_c
  12384.     bne.s    splend
  12385.     move.l    d4,d1
  12386.     move.l    a3,d2
  12387.     moveq    #0,d3
  12388.     jsr    _LVOSeek(a6)    skip part
  12389.     tst.l    d0
  12390.     bpl.s    sploop
  12391.     bra.s    splend
  12392.  
  12393. .B    bsr    OpenNewfile    open output file
  12394.     move.l    d0,d5        d5=output file handle
  12395.     bne.s    .D
  12396.     bsr    perr3
  12397.     bra.s    splend
  12398. .D    move.l    a3,d6        d6 holds filesize
  12399.     bsr    PerformCopy1    copy part to output
  12400.     bsr    check_c
  12401.     bne.s    splend
  12402.     tst.l    d0
  12403.     bne.s    .C
  12404.     lea    processOK(pc),a1    all OK
  12405.     bsr    pr_string
  12406. .C    moveq    #-1,d0
  12407.     cmp.l    d0,d6        check for input-fileend
  12408.     beq.s    sploop
  12409.  
  12410. splend    bsr    FreeCopyBlock
  12411.     move.l    d4,d1
  12412.     jsr    _LVOClose(a6)    close input
  12413.     moveq    #RETURN_OK,d0
  12414.     rts
  12415.  
  12416.  
  12417.  
  12418. manadr    dc.l    0    here are 2 global variables
  12419. mansize    dc.l    0    because the online-help-manual is used globally
  12420. loghandle    dc.l    0    global logfile filehandle
  12421.  
  12422.  
  12423. * Localized Error-Messages
  12424. doserror_text
  12425.     dc.b     48,'*** BREAK ***',0        304
  12426.     dc.b     49,'Not executable',0        305
  12427.     dc.b    103,'Not enough Memory',0
  12428.     dc.b    108,'Too small',0        -148
  12429.     dc.b    115,'Bad number',0
  12430.     dc.b    116,'Not enough Arguments',0
  12431.     dc.b    118,'Too many Arguments',0
  12432.     dc.b    119,'Unmatched Quotes',0
  12433.     dc.b    135,'Command not found',0    -121
  12434.     dc.b    137,'Syntax Error',0        -119
  12435.     dc.b    202,'Object in use',0
  12436.     dc.b    203,'Object '
  12437. exists        dc.b    'exists',0
  12438.     dc.b    204,'Dir not found',0
  12439.     dc.b    205,'Object'
  12440. notfund        dc.b    ' not found',0
  12441.     dc.b    209,'Action unknown',0
  12442.     dc.b    210,'Invalid Name',0
  12443.     dc.b    212,'Object wrong Type',0
  12444.     dc.b    213,'Not validated',0
  12445.     dc.b    214,'Disk write-protected',0
  12446.     dc.b    215,'Rename across Devices',0  
  12447.     dc.b    216,'Dir not empty',0
  12448.     dc.b    218,'Device not mounted',0
  12449.     dc.b    221,'Disk full',0
  12450.     dc.b    222,'Delete protected',0
  12451.     dc.b    223,'Write protected',0
  12452.     dc.b    225,'Not a DOS Disk',0
  12453.     dc.b    226,'No Disk present',0
  12454.  
  12455.     dc.b    101,'Error %3ld',0        -155
  12456.     dc.b    102,'Failat: %ld',10,0        -154
  12457.     dc.b    104,'Current Dir',0        -152
  12458.     dc.b    110,'Stack: %ld bytes',10,0    -146
  12459.     dc.b    127,'ZShell Process %ld',10,0    -129
  12460.     dc.b    0,0
  12461.  
  12462.  
  12463. *Standard-Strings
  12464. stringstart
  12465. iconname    dc.b    "icon.library",0
  12466. wbname        dc.b    "workbench.library",0
  12467. aslname        dc.b    "asl.library",0
  12468. guidename    dc.b    "amigaguide.library",0
  12469. timdev        dc.b    "timer.device",0
  12470. conname        dc.b    "CON:0/10/640/190/ZShell V2.8/CLOSE",0
  12471. connil        dc.b    "NIL:",0
  12472. devpipe        dc.b    "PIPE:",0
  12473. devtemp        dc.b    "T:",0
  12474. wintool        dc.b    "WINDOW",0
  12475. screentool    dc.b    "SCREEN",0
  12476. scripttool    dc.b    "SCRIPT",0
  12477. norawtool    dc.b    "NORAW",0
  12478. commandtool    dc.b    "COMMAND",0
  12479. iconifytool    dc.b    "ICONIFY",0
  12480. xpostool    dc.b    "XPOS",0
  12481. ypostool    dc.b    "YPOS",0
  12482. nametool    dc.b    "ICONNAME",0
  12483. helptool    dc.b    "HELPMAN",0
  12484. wbenchtx    dc.b    "Workbench",0
  12485. useit        dc.b    "Usage: ZShell [-Wwindow] [-Sscript]"
  12486.         dc.b    " [-Ccommand] [-Hhelpman] [-N] [-E] [-D]",0
  12487. onoffuse    dc.b    "ON or OFF ?",0
  12488. flagsuse    dc.b    "CHECK,MATCH,ICON,WILD,ERRORS,DEBUG"
  12489.         dc.b    ",CUT,ALL,HIDE,PIPE ?",0
  12490. iconuse        dc.b    "DISK,DRAWER,TOOL,PROJECT,GARBAGE"
  12491.         dc.b    ",DEVICE,KICK,APPICON ?",0
  12492. configuse    dc.b    "CTRLKEYS,MOREKEYS,DOT,HIDE,COLOUR"
  12493.         dc.b    ",COPYSIZE,FNCSIZE,LOGFILE ?",0
  12494. assignuse    dc.b    "REMOVE,ADD,PATH,DEFER ?",0
  12495. menuuse        dc.b    "TITLE,ITEM,SUBITEM,BAR,SUBBAR,END ?",0
  12496. softtx        dc.b    "SOFT",0
  12497. devicetx    dc.b    "DEVICE",0
  12498. forcetx        dc.b    "FORCE",0
  12499. alltx        dc.b    "ALL",0
  12500. defscript    dc.b    "S:ZStart",0    ;changed V2.0
  12501. rexxtx        dc.b    "REXX:RX",0
  12502. appicontx    dc.b    "Shell-It !",0
  12503. clkform        dc.b    ' Mem:%7ld Chip:%6ld  %02d:%02d:%02d ',0
  12504. warn_tx        dc.b    'warn',0
  12505. error_tx    dc.b    'error',0
  12506. fail_tx        dc.b    'fail',0
  12507. not_tx        dc.b    'not',0
  12508. oldkick_tx    dc.b    "Needs Kickstart 2.0+",0
  12509. nospace_tx    dc.b    "Missing Space",0
  12510. redirtwice    dc.b    "Double "
  12511. redir_tx    dc.b    "Redirection",0
  12512. badprotbit    dc.b    'Unknown flag',0
  12513. noclk_tx    dc.b    'No Clock',0
  12514. stack_tx    dc.b    'Stack overflow',0
  12515. bytes_tx    dc.b    '%ld Bytes',10,0
  12516. residetx    dc.b    27,'[32mUsecount  Name',27,'[m',0
  12517. rpn_result_tx    dc.b    'RESULT: Dec %ld  Hex $%08lx',10,0
  12518. rpn_res2    dc.b    '%ld',0
  12519. unmounted_tx    dc.b    '[Un'
  12520. mounted_tx    dc.b    'Mounted]',0
  12521. assign_tx    dc.b    10,27,'[32mAssigns:',27,'[m',10,0
  12522. volume_tx    dc.b    27,'[32mVolumes:',27,'[m',10,0
  12523. device1_tx    dc.b    10,27,'[32m',0
  12524. device2_tx    dc.b    'Disk-'
  12525. device3_tx    dc.b    'Devices:',27,'[m',10,0
  12526. prompt_args_tx    dc.b    4,'%P> ',0
  12527. lockread    dc.b    'READ',0
  12528. lockwrite    dc.b    'WRITE',0
  12529. locktext    dc.b    '$%06lx: %s-Lock on ',$9b,'33m%s',$9b,'m',10,0
  12530. numoflocks    dc.b    '%ld locks',10,0
  12531. clk_tx        dc.b    'LOAD or SAVE ?',0
  12532. muell_tx    dc.b    'Format: DD.MM.YY or MM-DD-YY or HH:MM:SS',0
  12533. styp        dc.b    'lrdimps'
  12534. shuse_tx    dc.b    'Use D,I,L,M,P,R,S,T or V',0
  12535. show_tx        dc.b    $9b,'32mAdress Pri Name',$9b,'m',0
  12536. show2_tx    dc.b    $9b,'32mAdress Pri Ver Rev Name',$9b,'m',0
  12537. shform        dc.b    '%06lx%4d %s',10,0
  12538. shform2        dc.b    '%06lx%4d%4d%4d %s',10,0
  12539. shta_tx        dc.b    $9b,'32mAdress Pri State SignWait PT '
  12540.         dc.b    'Name',$9b,'m',0
  12541. shtaform    dc.b    '%06lx%4d %-5s %08lx %c%c %s',0
  12542. proform        dc.b    32,9,$9b,'33m->%sCLI %ld:',$9b,'m %s %s%s',0
  12543. backcli        dc.b    "Bg-",0
  12544. ttyp        dc.b    "Inval",0,"Added",0,"Run",0,"Ready",0
  12545.         dc.b    "Wait",0,"Exept",0,"Remov",0
  12546. inform_tx    dc.b    $9b,'32mName Unit Sys    Size    Free Full Block'
  12547.         dc.b    '   Status   Err  Volume',$9b,'m',0
  12548. inform        dc.b    '%-7s%2ld %3s%7ldK%7ldK',$9b,'37m%4ld%%',$9b
  12549.         dc.b    'm%6ld %-10s%3ld   %s',10,0
  12550. inform2        dc.b    '%-7s%2ld     ',$9b,'35m%s',$9b,'m',10,0
  12551. statro        dc.b    "Read only",0
  12552. statrw        dc.b    "Read/Write",0
  12553. statval        dc.b    "Validating",0
  12554. statun        dc.b    "Unknown",0
  12555. kickdisk    dc.b    "Kick",0
  12556. ofs_tx        dc.b    "OFS",0    OldFilesystem
  12557.         dc.b    "FFS",0    FastFilesystem
  12558.         dc.b    "OIN",0    International OFS
  12559.         dc.b    "FIN",0    International FFS
  12560.         dc.b    "ODC",0    Dir Cache OFS
  12561.         dc.b    "FDC",0 Dir Cache FFS
  12562. msd_tx        dc.b    "MSD",0    MessyDOS
  12563. quest_tx    dc.b    "???",0    Unknown
  12564. msendtx        dc.b    "sent",0
  12565. pra5tx        dc.b    "A5=%06lx",10,0
  12566. msgtx        dc.b    "Message=%06lx  Length=%d",10,0
  12567. time_text    dc.b    "Date: %02d.%02d.%02d    "
  12568.         dc.b    "Time: %02d:%02d:%02d.%02d",10,0
  12569. stat_text    dc.b    27,"[37mResult2=%ld  Time=%02d:%02d:%02d.%02d"
  12570.         dc.b    "  Changes-> Chip:%ld  Fast:%ld  Total:%ld"
  12571.         dc.b    27,"[m",10,0
  12572. lowmemtx    dc.b    "Changed %06lx: %08lx -> %08lx",10,0
  12573. replytx        dc.b    "Reply? ",0
  12574. mem_line    dc.b    "%08lx: %08lx %08lx %08lx %08lx   '%s'",10,0
  12575. vec_line    dc.b    "Warm $%08lx MemPtr $%08lx",10
  12576.         dc.b    "Cool $%08lx TagPtr $%08lx",10
  12577.         dc.b    "Cold $%08lx Check  $%08lx",10,0
  12578. formatask    dc.b    "Delete whole disk ? ",0
  12579. addbufftx    dc.b    "%s has %ld buffers",10,0
  12580. pfeil        dc.b    "-> ",0
  12581. flagsoff    dc.b    ": OFF",10,0
  12582. flagson        dc.b    ": ON",10,0
  12583. name_tx        dc.b    "Name: ",0
  12584.  
  12585. format        dc.b    '%8ld',0    ;print a longw right justified
  12586. formatADR    dc.b    '$%06lx',0    ;print address 
  12587. totsize        dc.b    27,'[37mTotal Bytes: %ld  Blocks: %ld   '
  12588.         dc.b    'Files: %ld  Dirs: %ld',27,'[m',10,0
  12589. dirtext        dc.b    '(Dir)',27,'[m',0
  12590. dirof        dc.b    27,'[36mDirectory of ',27,'[m',0
  12591. paths        dc.b    "S:",0
  12592. msearch        dc.b    12,$9b,'BSearch: ',$9b," p",0
  12593. mjump        dc.b    12,$9b,'BJump to %: ',$9b," p",0
  12594. mwrite        dc.b    12,$9b,'BWrite to: ',$9b," p",0
  12595. wrongsize    dc.b    'New size:',0
  12596. makedirOK    dc.b    'created',10,0
  12597. copyOK        dc.b    'copied',10,0
  12598. moveOK        dc.b    'moved',10,0
  12599. processOK    dc.b    'processed',10,0
  12600. deleteOK    dc.b    'deleted',10,0
  12601. yesnotx        dc.b    'Yes/No/All/Quit ? ',0
  12602. memess        dc.b    "Chip: %ld  Fast: %ld  Total Free: %ld",10,0
  12603.  
  12604. star        dc.b    "*",0
  12605. dot        dc.b    ".",0
  12606. smaller        dc.b    "<",0
  12607. bigger        dc.b    ">",0
  12608. lf        dc.b    10,0
  12609. tab        dc.b    9,0
  12610. space        dc.b    " "
  12611. null        dc.b    0
  12612. help_ret    dc.b    "^XHELP^M",0
  12613. farb1        dc.b    27,'[m',0
  12614. farb2        dc.b    27,'[32m',0
  12615. farb3        dc.b    27,'[33m',0
  12616. delete_line    dc.b    13,$9b,'M',0
  12617. clstx        dc.b    27,"c",0    reset console
  12618. clrtx        dc.b    12,0    clear screen
  12619. scroll_up_tx    dc.b    $9b,"S",13,0
  12620. scroll_down_tx    dc.b    $9b,"M",$9b,"T",$9b,"1H",0
  12621. clrhide        dc.b    12
  12622. hide_cursor    dc.b    $9b,"0 p",0
  12623. show_cursor    dc.b    $9b," p",0
  12624. cutontx        dc.b    $9b,"?7l",0
  12625. cutofftx    dc.b    $9b,"?7h",0
  12626. menuon_tx    dc.b    $9b,"10{",0
  12627. menuoff_tx    dc.b    $9b,"10}",0
  12628.         even
  12629.  
  12630. recol1    dc.w    residetx+3-stringstart
  12631.     dc.w    assign_tx+4-stringstart
  12632.     dc.w    volume_tx+3-stringstart
  12633.     dc.w    device1_tx+4-stringstart
  12634.     dc.w    show_tx+2-stringstart
  12635.     dc.w    show2_tx+2-stringstart
  12636.     dc.w    shta_tx+2-stringstart
  12637.     dc.w    proform+4-stringstart
  12638.     dc.w    inform_tx+2-stringstart
  12639.     dc.w    inform+24-stringstart
  12640.     dc.w    inform2+15-stringstart
  12641.     dc.w    stat_text+3-stringstart
  12642.     dc.w    totsize+3-stringstart
  12643.     dc.w    dirof+3-stringstart
  12644.     dc.w    farb2+3-stringstart
  12645.     dc.w    farb3+3-stringstart
  12646. ;    dc.w    helpmor+3-stringstart
  12647. recol2    ;Recolour-table to switch globally to one colour
  12648.     dc.b    2,2,2,2,2,2,2,3,2,7,5,7,7,6,2,3        ;,2
  12649.     even
  12650.  
  12651.  
  12652. comtext    dc.b    2,'AddBuffers',0    V1.27
  12653.     dc.b    -1,'Alias',0
  12654.     dc.b    -1,'Ask',0        V1.28
  12655.     dc.b    3,'Assign',0
  12656.     dc.b    1,'Avail',0
  12657.     dc.b    2,'Border',0        V2.0
  12658.     dc.b    2,'Break',0        V2.0
  12659.     dc.b    1,'CD',0
  12660.     dc.b    0,'Cls',0        V2.0
  12661.     dc.b    3,'Config',0        V2.0
  12662.     dc.b    -1,'Copy',0
  12663.     dc.b    2,'Date',0
  12664.     dc.b    -1,'Delete',0
  12665.     dc.b    -1,'Dir',0
  12666.     dc.b    1,'DiskChange',0    V2.0
  12667.     dc.b    -1,'Echo',0
  12668. elsetx    dc.b    0,'Else',0        V1.28
  12669. endcltx    dc.b    1,'EndCLI',0
  12670. endiftx dc.b    0,'EndIf',0        V1.28
  12671.     dc.b    -1,'Eval',0
  12672. exectx    dc.b    -1,'Execute',0
  12673.     dc.b    1,'FailAt',0
  12674.     dc.b    1,'Fault',0        V2.0
  12675.     dc.b    2,'FileNote',0        V2.0
  12676.     dc.b    -1,'Flags',0        V2.3
  12677.     dc.b    1,'GetMsg',0        V2.0
  12678.     dc.b    1,'Help',0
  12679.     dc.b    2,'HType',0        V1.29
  12680.     dc.b    3,'If',0        V1.28
  12681.     dc.b    0,'Info',0
  12682.     dc.b    -1,'Join',0        V1.29
  12683.     dc.b    1,'Kill',0        V2.0
  12684. labeltx dc.b    1,'Lab',0        V1.29
  12685.     dc.b    -1,'List',0
  12686.     dc.b    3,'Locate',0        V2.0
  12687.     dc.b    2,'Lock',0        V2.0
  12688.     dc.b    2,'M',0
  12689.     dc.b    -1,'MakeDir',0
  12690.     dc.b    2,'MakeIcon',0        V2.3
  12691.     dc.b    3,'MakeLink',0        V2.3
  12692. clktask    dc.b    2,'MemClk',0        V2.0
  12693.     dc.b    2,'More',0        V1.23
  12694.     dc.b    -1,'Move',0        V2.3
  12695.     dc.b    -1,'NewCLI',0        V2.0
  12696.     dc.b    -1,'Path',0
  12697.     dc.b    1,'Prompt',0
  12698.     dc.b    -1,'Protect',0
  12699.     dc.b    -1,'PutMsg',0        V2.0
  12700.     dc.b    1,'Quit',0        V1.29
  12701.     dc.b    2,'Relabel',0        V1.27
  12702.     dc.b    2,'Rename',0
  12703.     dc.b    -1,'Resident',0        V1.25
  12704.     dc.b    2,'Review',0        V2.1
  12705.     dc.b    -1,'Run',0        V2.2
  12706.     dc.b    2,'Search',0        V2.0
  12707.     dc.b    1,'SetClock',0        V2.0
  12708.     dc.b    3,'SetDate',0        V2.0
  12709.     dc.b    1,'Show',0        V2.0
  12710.     dc.b    1,'Skip',0
  12711.     dc.b    5,'Split',0        V2.6
  12712.     dc.b    1,'Stack',0
  12713.     dc.b    2,'Strings',0        V1.29
  12714.     dc.b    2,'TaskPri',0        V2.0
  12715.     dc.b    1,'Type',0
  12716.     dc.b    -1,'UnAlias',0
  12717.     dc.b    1,'Wait',0
  12718.     dc.b    0,0
  12719.     even    
  12720.  
  12721. comoffs
  12722.     dc.w    addbuffersz-cmdstart
  12723.     dc.w    aliasz-cmdstart
  12724.     dc.w    askz-cmdstart
  12725.     dc.w    assignz-cmdstart
  12726.     dc.w    availz-cmdstart
  12727.     dc.w    borderz-cmdstart
  12728.     dc.w    breakz-cmdstart
  12729.     dc.w    cdz-cmdstart
  12730.     dc.w    clsz-cmdstart
  12731.     dc.w    configz-cmdstart
  12732.     dc.w    copyz-cmdstart
  12733.     dc.w    datez-cmdstart
  12734.     dc.w    deletez-cmdstart
  12735.     dc.w    dirz-cmdstart
  12736.     dc.w    diskchangez-cmdstart
  12737.     dc.w    echoz-cmdstart
  12738.     dc.w    elsez-cmdstart
  12739.     dc.w    endcliz-cmdstart
  12740.     dc.w    endifz-cmdstart
  12741.     dc.w    evalz-cmdstart
  12742.     dc.w    executez-cmdstart
  12743.     dc.w    failatz-cmdstart
  12744.     dc.w    faultz-cmdstart
  12745.     dc.w    filenotez-cmdstart
  12746.     dc.w    flagsz-cmdstart
  12747.     dc.w    getmsgz-cmdstart
  12748.     dc.w    helpz-cmdstart
  12749.     dc.w    htypez-cmdstart
  12750.     dc.w    ifz-cmdstart
  12751.     dc.w    infoz-cmdstart
  12752.     dc.w    joinz-cmdstart
  12753.     dc.w    killz-cmdstart
  12754.     dc.w    labelz-cmdstart    ;lab
  12755.     dc.w    listz-cmdstart
  12756.     dc.w    locatez-cmdstart
  12757.     dc.w    lockz-cmdstart
  12758.     dc.w    memexamz-cmdstart    ;m
  12759.     dc.w    makedirz-cmdstart
  12760.     dc.w    makeiconz-cmdstart
  12761.     dc.w    makelinkz-cmdstart
  12762.     dc.w    memclkz-cmdstart
  12763.     dc.w    morez-cmdstart
  12764.     dc.w    movez-cmdstart
  12765.     dc.w    newcliz-cmdstart
  12766.     dc.w    pathz-cmdstart
  12767.     dc.w    promptz-cmdstart
  12768.     dc.w    protectz-cmdstart
  12769.     dc.w    putmsgz-cmdstart
  12770.     dc.w    quitz-cmdstart
  12771.     dc.w    relabelz-cmdstart
  12772.     dc.w    renamez-cmdstart
  12773.     dc.w    residentz-cmdstart
  12774.     dc.w    reviewz-cmdstart
  12775.     dc.w    runz-cmdstart
  12776.     dc.w    searchz-cmdstart
  12777.     dc.w    setclockz-cmdstart
  12778.     dc.w    setdatez-cmdstart
  12779.     dc.w    showz-cmdstart
  12780.     dc.w    skipz-cmdstart
  12781.     dc.w    splitz-cmdstart
  12782.     dc.w    stackz-cmdstart
  12783.     dc.w    stringsz-cmdstart
  12784.     dc.w    taskpriz-cmdstart
  12785.     dc.w    typez-cmdstart
  12786.     dc.w    unaliasz-cmdstart
  12787.     dc.w    waitz-cmdstart
  12788.  
  12789.  
  12790.     end    ;***    here it ends    ***
  12791.  
  12792.